[英]How to run Docker Container in Spyder
I have docker image/container with virtual environment and currently I'm able to run it in VS Code using Remote Development extension.我有带有虚拟环境的 docker 映像/容器,目前我可以使用远程开发扩展在 VS Code 中运行它。 Is it possible to do something similar in Spyder?
是否可以在 Spyder 中做类似的事情?
EDIT: That's what I've done so far:编辑:这就是我到目前为止所做的:
My dockerfile:我的码头文件:
FROM ubuntu:latest
RUN apt update && apt install openssh-server sudo -y
# Create a user “sshuser” and group “sshgroup”
RUN groupadd sshgroup && useradd -ms /bin/bash -g sshgroup sshuser
# Create sshuser directory in home
RUN mkdir -p /home/sshuser/.ssh
# Copy the ssh public key in the authorized_keys file. The idkey.pub below is a public key file you get from ssh-keygen. They are under ~/.ssh directory by default.
COPY key.pub /home/sshuser/.ssh/authorized_keys
# change ownership of the key file.
RUN chown sshuser:sshgroup /home/sshuser/.ssh/authorized_keys && chmod 600 /home/sshuser/.ssh/authorized_keys
# Start SSH service
RUN service ssh start
# Expose docker port 22
EXPOSE 22
CMD ["/usr/sbin/sshd","-D"]
USER root
RUN apt update
RUN apt-get install python3-pip -y
RUN pip install jupyter
RUN pip install spyder-kernels
Then in powershell I typed:然后在powershell中我输入:
docker run -d -p 2022:22 sshubuntu
ssh -i key sshuser@localhost -p 2022 # (here I typed my password and successfully logged into container)
jupyter --runtime-dir # /home/sshuser/.local/share/jupyter/runtime
python3 -m spyder_kernels.console
Now using another instance of powershell I copied json
to local machine:现在使用另一个powershell实例,我将
json
复制到本地机器:
docker cp 21ff6e147a2d:/home/sshuser/.local/share/jupyter/runtime/kernel-24.json .
The file is:该文件是:
{
"shell_port": 46227,
"iopub_port": 34519,
"stdin_port": 43075,
"control_port": 38781,
"hb_port": 44761,
"ip": "127.0.0.1",
"key": "1c925c4a-983896e82c953e4fccb7ce90",
"transport": "tcp",
"signature_scheme": "hmac-sha256",
"kernel_name": ""
}
Finally I opened Spyder and typed the following:最后我打开 Spyder 并输入以下内容:
The results is that "Connecting to kernel..." appears and nothing happenes.结果是“连接到内核...”出现并且没有任何反应。 What am I doing wrong that it doesnt work?
我做错了什么,它不起作用?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.