Part 1 — Remote Developing with PyCharm [Docker SSH Server]
In this part, you will learn how to start developing using PyCharm and Docker.
Table of contents
Step 1 — Create a working directory
The first thing you need to do is to create a directory in which you can store docker and ssh related files.
As an example, we will create a directory named remote_dev inside our project and move into that directory with the command:
Step 2 — Create SSH key
On your client system – the one you’re using to connect to the server – you need to create a pair of key codes.
To generate a pair of SSH key codes, enter the command:
Files my_key
and my_key.pub
will be created in the working directory.
Step 3 — Docker Image
Let's create all the files necessary for building the container.
1. Create Dockerfile
Let's create a simple image in which we will deploy the SSH server:
remote_dev/Dockerfile
Add a script to start the server:
remote_dev/sshd_daemon.sh
2. Create docker-compose
Since we need a GPU inside the container, we will take Image with pre-installed CUDA as a basis and set runtime to nvidia. For convenience, let's create a docker-compose file:
remote_dev/docker-compose.yml
3. Build container
Don't forget to install docker and nvidia-docker2
The basic syntax used to build an image using a docker-compose is:
Once the image is successfully built, you can verify whether it is on the list of containers with the command:
Step 4 — Connect to container over SSH
Add server with the ports specified in docker-compose.yml
~/.ssh/config (example)
To connect to container by SSH, use command:
Step 5 — Connect to container in PyCharm
1. Create new project
2. Add new interpreter
Open Preferences -> Python Interpreter
Show all
Plus button
3. Configure interpreter
4. Run simple code
Last updated