pycharm connects docker container remotely
- 1. Create a container based on the image
- 2. Enter the container
- 3. Modify the root password of the container
- 4. Install openssh-server and openssh-client in the container
- 5. Modify the SSH configuration file
- 6. Restart the ssh service
- 7. Exit test
- 8. Configure pycharm and connect docker container
- 9. Select the docker environment
1. Create a container based on the image
sudo docker run -itd --name=conn_test --runtime=nvidia --gpus all -p 8089:22 test:v1
2. Enter the container
sudo docker exec -it f08beeff759a /bin/bash
3. Modify the root password of the container
passwd
4. Install openssh-server and openssh-client in the container
# apt-get -y update 如果下面命令报错,先执行这个命令,再重新执行下面的命令
apt-get install openssh-server
apt-get install openssh-client
5. Modify the SSH configuration file
- edit file
vim /etc/ssh/sshd_config
- add content
PermitRootLogin yes # 允许root用户使用ssh登录
6. Restart the ssh service
/etc/init.d/ssh restart
7. Exit test
ssh [email protected] -p 8089
8. Configure pycharm and connect docker container
-
step one
-
step two
-
step three
9. Select the docker environment
- Configuration Environment
- test, run the file
- View interpreter path is not local, success