Use host.docker.internal instead of 0.0.0.0. This will allow docker to decide which IP to use.

Answer from Drew Rochon on Stack Overflow
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ pycharm โ€บ using-docker-as-a-remote-interpreter.html
Configure an interpreter using Docker | PyCharm Documentation
March 17, 2026 - Wait for PyCharm to connect to the Docker daemon and complete the container introspection. Select an interpreter to use in the Docker container. You can select a Python, conda or uv environment type.
๐ŸŒ
Supervisely
developer.supervisely.com โ€บ app-development โ€บ advanced โ€บ in-depth-app-development โ€บ chapter-4-additionals โ€บ part-1-remote-developing-with-pycharm-docker-ssh-server
Part 1 โ€” Remote Developing with PyCharm [Docker SSH Server] | Supervisely
August 31, 2022 - ... 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:
Discussions

ssh - Pycharm - using remote Docker container as interpreter - Stack Overflow
I was told on the PyCharm forums that this is likely to be a bug, so not much to do at the moment. However, if you use PyCharm Pro, there's a new Beta functionality which allows you to SSH into remote hosts...it's the "Remote Development โ†’ SSH" option, accessible through the "Welcome to PyCharm" ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - PyCharm remote debug in a docker container - Stack Overflow
I'm having an hard time trying to figure out how to setup a remote debug of a python app (Flask) running in a Docker container. Specifically I'm using docker-compose, PyCharm professional and pytho... More on stackoverflow.com
๐ŸŒ stackoverflow.com
ssh - Pycharm use Docker Container Python as Remote Interpreter - Stack Overflow
But I don't much like using Jupyter for developing and would like to use the Python interpreter in the Docker Container in Pycharm. When I select "Add Python Interpreter" in Pycharm, I get the following options: The documentation for Pycharm suggests using the "Add Python Interpreter/Docker" tool which looks like this: However the documentation doesn't say how to set up the Docker container and the connections if the Docker is on a remote ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Is there an equivalent of the VS Code remote development in PyCharm?
I have exactly the same question: I have a linux machine with my python code (~/documents/my_web_app) and on the same machine there's the python environment and other resources (Kibana, Elasticsearch). I would like to do remote development from my windows machine through SSH and forward some ports (5000 and 5601). I am new to remote development from PyCharm, from what i could understand it sets-up an SSH connection for the code, and another SSH connection for the python environment and the port forwarding. the problem is that it uploads the whole repo again to the machine to the sync folder when i ask to run tests or debug the code which is unnecessary since the code is already there. I'm looking for something like VSCode offers: https://code.visualstudio.com/docs/remote/ssh More on reddit.com
๐ŸŒ r/pycharm
10
7
June 18, 2024
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ pycharm โ€บ docker.html
Docker | PyCharm Documentation
1 month ago - Docker Buildx plugin, which is necessary for building images from Dockerfile. Note that using Buildx with Docker requires Docker Engine version 19.03 or later. For Dev Containers on a remote server, refer to Limitations.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 76051437 โ€บ pycharm-using-remote-docker-container-as-interpreter
ssh - Pycharm - using remote Docker container as interpreter - Stack Overflow
Selecting New Project, you can select between the possible SSH configurations available in PyCharm (you can set them up through Setting โ†’ Tools โ†’ SSH Configurations). The whole thing is actually much more similar to how VS Code works. It downloads some helpers and open a remote PyCharm instance directly on the remote machine, and you can work there. I tested it, and it works in remote docker containers as well.
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ pycharm โ€บ connect-to-devcontainer.html
Dev Container overview | PyCharm Documentation
October 23, 2024 - The container can be run in a remote environment, and its resources and capabilities become available during development. In PyCharm, there are various scenarios that you can use to start a Dev Container:
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ pycharm โ€บ start-dev-container-for-a-remote-project.html
Start Dev Container for a remote project | PyCharm Documentation
February 5, 2026 - In addition, ensure you have Java ... project located in the remote file system. Launch PyCharm. On the left-hand pane of the Welcome screen, click Remote Development....
๐ŸŒ
GitHub
gist.github.com โ€บ costa โ€บ 204dccca4543dc518370947d33955f9a
Setting up remote (really remote) containerised development environment with PyCharm (Medium blogpost) ยท GitHub
Make a copy of your Python component's Dockerfile (Dockerfile.remote-dev) with the following changes: ... Other python versions are available upon request -- I've made a very simple image (FROM python:2.7) based on https://github.com/eugene-s/python-sshd (FROM python:2.7, not Alpine or anything) which I'm using here. b) Remove your ENTRYPOINT/CMD -- the component will be running sshd now and PyCharm will be running Python scripts through it.
Find elsewhere
๐ŸŒ
GitHub
github.com โ€บ tkat0 โ€บ cookiecutter-pycharm-remote-docker
GitHub - tkat0/cookiecutter-pycharm-remote-docker: PyCharm project template for development in remote docker environment
December 10, 2018 - Add new Docker configuration (e.g. Docker-remote) and set as follows. This name is used later. ... By answering some questions, project directory are automatically generated. # Create a project from cookiecutter-pycharm-remote-docker template $ cookiecutter git@github.com:tkat0/cookiecutter-pycharm-remote-docker.git full_name [Your Name]: tkat0 email [Your email]: tkato.dev@gmail.com" project_name [project_name]: sample-project project_slug [sample_project]: project_short_description []: sample project version [0.1.0]: timezone [Asia/Tokyo]: python_version [3.6.0]: remote_host [remote machine ip-addr or host-name]: 192.168.0.2 remote_docker_name [Docker-remote]: remote_uid [remote user id (result of "ssh 192.168.0.2 id -u")]:1003 remote_work_dir [remote working directory.
Starred by 41 users
Forked by 3 users
Languages ย  Python 77.1% | Dockerfile 15.1% | Makefile 7.0% | Shell 0.8% | Python 77.1% | Dockerfile 15.1% | Makefile 7.0% | Shell 0.8%
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ pycharm โ€บ using-docker-compose-as-a-remote-interpreter.html
Configure an interpreter using Docker Compose | PyCharm Documentation
March 17, 2026 - Specify the docker-compose.yml file in Configuration files and select the service. Optionally, specify environment variables and edit the Compose project name. Wait until PyCharm creates and configures a new target: Select an interpreter to use in the container. You can select a Python, conda or uv environment type. ... The configured remote ...
๐ŸŒ
Pauleveritt
pauleveritt.github.io โ€บ posts โ€บ docker_intro
Using Docker in PyCharm โ€” Paul Everitt documentation
Once that Docker image is locally available and the Docker โ€œhostโ€ is running and knows about it, PyCharm can make Docker interpreters for your project, as containers based on that image. Alternatively, you can skip this step and later pull in the image while creating the Docker-based remote interpreter by simply typing in the image name during creation.
๐ŸŒ
JetBrains
youtrack.jetbrains.com โ€บ issue โ€บ PY-33489 โ€บ Native-support-for-running-Docker-on-the-remote-machine
Native support for running Docker on the remote machine
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
Top answer
1 of 1
3

Thank you for depicting the dilemma so poignantly and clearly in your cartoon :-). My colleague and I were trying to do something similar and what ultimately worked beautifully was creating an SSH config directly to the Docker container jumping from the remote machine, and then setting it as a remote SSH interpreter so that pycharm doesn't even realize it's a Docker container. It also works well for vscode.

  1. set up ssh service in docker container (subset of steps in https://dev.to/s1ntaxe770r/how-to-setup-ssh-within-a-docker-container-i5i, port22 stuff wasn't needed)
    • docker exec -it <container> bash: create admin interactive prompt for docker
    • apt-get install openssh-server
    • service ssh start
    • confirm with service ssh status -> * sshd is running
  2. determine IP and test SSHing from remote machine into container (adapted from https://phoenixnap.com/kb/how-to-ssh-into-docker-container, steps 2 and 3)
    • from normal command prompt on remote machine (not within container): docker inspect -f "{{ .NetworkSettings.IPAddress }}" <container> to get container IP
    • test: ping -c 3 <container_ip>
    • ssh: ssh <container_ip>; should drop you into the container as your user; however, requires container to be configured properly (docker run cmd has -v /etc/passwd:/etc/passwd:ro \ etc.). It may ask for a password. note: if you do this for a different container later that is assigned the same IP, you will get a warning and may need to delete the previous key from known_hosts; just follow the instructions in the warning.
  3. test SSH from local machine
    • if you don't have it set up already, set up passwordless ssh key-based authentication to the remote machine with the docker container
    • make SSH command that uses your remote machine as a jump server to the container: ssh -J <remote_machine> <container_ip>, as described in https://wiki.gentoo.org/wiki/SSH_jump_host; if successful you should drop into the container just as you did from the remote machine
    • save this setup in your ~/.ssh/config; follow the ProxyJump Example from https://wiki.gentoo.org/wiki/SSH_jump_host
    • test config with ssh <container_host_name_defined_in_ssh_config>; should also drop you into interactive container
  4. configure pycharm (or vscode or any IDE that accepts remote SSH interpreter)
    • Preferences -> Project -> Python Interpreter -> Add -> SSH Interpreter -> New server configuration
    • host: <container_host_name_defined_in_ssh_config>
    • port: 22
    • username: <username_on_remote_server>
    • select interpreter, can navigate using the folder icon, which will walk you through paths within the docker, or you can enter the result of which python from the container
    • follow pycharm prompts
๐ŸŒ
JetBrains
intellij-support.jetbrains.com โ€บ hc โ€บ en-us โ€บ community โ€บ posts โ€บ 4407769339538-How-Remote-Docker-interpreter-runs-in-remote-server-
How Remote Docker interpreter runs in remote server? โ€“ IDEs Support (IntelliJ Platform) | JetBrains
October 5, 2021 - Connect via SSH to Docker engine running on a remote machine and use the remote machine as a development environment for Visual Studio Code.We created a project and added a Python script.
๐ŸŒ
JetBrains
jetbrains.com โ€บ help โ€บ pycharm โ€บ settings-docker.html
Docker connection settings | PyCharm Documentation
February 24, 2026 - Connect to a remote Docker daemon via an existing SSH configuration or create a new one. ... Connect to a Docker daemon running in Windows Subsystem for Linux (WSL). ... If you are running minikube, select this option to automatically detect ...
๐ŸŒ
JetBrains
blog.jetbrains.com โ€บ pycharm โ€บ 2015 โ€บ 12 โ€บ using-docker-in-pycharm
Using Docker in PyCharm | The PyCharm Blog
January 17, 2024 - Once that Docker image is locally available and the Docker โ€œhostโ€ is running and knows about it, PyCharm can make Docker interpreters for your project, as containers based on that image. Alternatively, you can skip this step and later pull in the image while creating the Docker-based remote interpreter by simply typing in the image name during creation.
Top answer
1 of 10
14

UPDATE: PyCharm 2017.1 has a solution for this problem, see this blog entry

Here is how I solved the problem. My circumstances are that I was assigned to do an intervention on a specific area of a web app that used docker-compose to create a set of four containers. Docker-compose is a kind of meta docker that manages multiple docker containers from one command. I did not want to mangle their existing setup since so many things depend on it. But since I was working on one specific part in one of the images I decided that I would extend one of the containers with ssh so that I could debug from PyCharm. Further, I wanted the app to run as normal when started and only by forcing it to quit and then connecting to it from PyCharm would I have a debuggable component. Here is what I did on my mac that uses boot2docker (on VirtualBox) to setup docker correctly.

First, I need to extend the target container, called jqworker. I am going to use "supervisior" to do the heavy lifting of managing things.

CopyFROM jqworker

# Get supervisor to control multiple processes, sshd to allow connections.
# And supervisor-stdout allows us to send the output to the main docker output.
RUN apt-get update && apt-get install -y supervisor openssh-server python-pip \
  && pip install supervisor-stdout \
  && mkdir -p /var/run/sshd  \
  && mkdir -p /var/log/supervisor \
  && mkdir -p /etc/supervisor/conf.d

COPY ./supervisord.conf /etc/supervisor/conf.d/supervisord.conf

# Fix up SSH, probably should rip this out in real deploy situations.
RUN echo 'root:soup4nuts' | chpasswd
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config

# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile

# Expose SSH on 22, but this gets mapped to some other address.
EXPOSE 22

# Replace old entrypoint with supervisiord, starts both sshd and worker.py
ENTRYPOINT ["/usr/bin/supervisord"]

Supervisor lets me run multiple tasks from one command, in this case the original command and SSHD. Yes, everyone says that SSHD in docker is evil and containers should this and that and blah blah, but programming is about solving problems, not conforming to arbitrary dicta that ignore context. We need SSH to debug code and are not deploying this to the field, which is one reason we are extending the existing container instead of adding this in to the deployment structure. I am running it locally so that I can debug the code in context.

Here is the supervisord.conf file, note that I am using the supervisor-stdout package to direct output to supervisor instead of logging the data as I prefer to see it all in one place:

Copy[supervisord]
nodaemon=true

[program:sshd]
command=/usr/sbin/sshd -D

[program:worker]
command=python /opt/applications/myproject/worker.py -A args
directory=/opt/applications/myproject
stdout_events_enabled=true
stderr_events_enabled=true

[eventlistener:stdout]
command = supervisor_stdout
buffer_size = 100
events = PROCESS_LOG
result_handler = supervisor_stdout:event_handler

I have a build directory containing the above two files, and from a terminal in there I build the Dockerfile with:

Copydocker build -t fgkrqworker .

This adds it so that I can call it from docker or docker-compose. Don't skip the trailing dot!

Since the app uses docker-compose to run a set of containers, the existing WORKER container will be replaced with one that solves my problems. But first I want to show that in another part of my docker-compose.yml I define a mapping from the containers to my local hard drive, this is one of a number of volumes being mapped:

Copyvolumes: &VOLUMES
  ? /Users/me/source/myproject:/opt/applications/myproject

Then the actual definition for my container, which references the above VOLUMES:

Copyjqworker: &WORKER
  image: fgkrqworker
  privileged: true
  stdin_open: true
  detach: true
  tty: true
  volumes:
    <<: *VOLUMES
  ports:
    - "7722:22"

This maps the SSH port to a known port that is available in the VM, recall I am using boot2docker which rides on VirtualBox, but the needs to be mapped out to where PyCharm can get at it. In VirtualBox, open the boot2docker VM and choose Adapter 1. Sometimes the "Attached to:" combo unselects itself, so watch for that. In my case it should have NAT selected.

Click "Port Forwarding" and map the inner port to the a port on localhost, I choose to use the same port number. It should be something like:

  • Name: ssh_mapped;
  • Protocol: TCP;
  • Host IP:127.0.0.1;
  • Host Port:7722;
  • Guest IP:;
  • Guest Port: 7722

Note: be careful not to change the boot2docker ssh setting or you will eventually be unable to start the VM correctly.

So, at this point we have a container that extends my target container. It runs ssh on port 22 and maps it to 7722 since other containers might want to use 22, and is visible in the VirtualBox environment. VirtualBox maps 7722 to 7722 to the localhost and you can ssh into the container with:

Copyssh root@localhost -p 7722

Which will then prompt for the password, 'soup4nuts' and you should be able to locate something specific to your container to verify that it is the right one and that everything works OK. I would not mess with root if I were deploying this anywhere but my local machine, so be warned. This is only for debugging locally and you should think twice or thrice about doing this on a live site.

At this point you can probably figure the rest of it out if you have used PyCharm's remote debugging. But here is how I set it up:

First, recall that I have docker-compose.yml mapping the project directory:

Copy? /Users/me/source/myproject:/opt/applications/myproject 

In my container /opt/applications/myproject is actually /Users/me/source/myproject on my local hard drive. So, this is the root of my project. My PyCharm sees this directory as the project root and I want PyCharm to write the .pycharm_helpers here so that it persists between sessions. I am managing source code on the mac side of things, but PyCharm thinks it is a unixy box elsewhere. Yes, it is a bit of kludge until JetBrains incorporates a Docker solution.

First, go to the Project X/Project Structure and create a Content Root of the local mapping, in my case that means /Users/me/source/myproject

Later, come back and add .pycharm_helpers to the excluded set, we don't want this to end up in source control or confuse PyCharm.

Go to the Build, Execution, Deployment tab, pick Deployment and create a new Deployment of SFTP type. The host is localhost, the port 7722, the root path is /opt/applications/myproject and the username is root and password is soup4nuts and I checked the option to save the password. I named my Deployment 'dockercompose' so that I would be able to pick it out later.

On the Deployment Mappings tab I set the local path to /Users/me/source/myproject and deployment and web path to a single '/' but since my code doesn't correspond to a URL and I don't use this to debug, it is a placeholder in the Web Path setting. I don't know how you might set yours.

On the Project X/Project Interpreter tab, create a new Remote Python Interpreter. You can pick the Deployment Configuration and choose the dockercompose configuration we created above. The host URL should fill in as ssh://root@localhost:7722 and the Python Interpreter Path will likely be /usr/bin/python. We need to set the PyCharm Helpers Path as the default will not survive the container being redone. I actually went to my project local directory and created a .pycharm_helpers directory in the root, then set the path here as /opt/applications/myproject/.pycharm_helpers and when I hit the OK button it copied the files "up" to the directory. I don't know if it will create it automatically or not.

Don't forget that the .pycharm_helpers directory should probably be excluded on the project roots tab.

At this point you can go to the Build, Execution, Deployment tab, and under Console/Python Console, pick the remote interpreter we created above and set the working directory to /opt/applications/myproject and you can run your Python Console in the container if you like.

Now you need to create a Run Configuration so that you can remotely debug your python code. Make a new Python configuration and set the script to the one that used to start the python code in the container. Mine, from the supervisor setup, above is:

Copy/opt/applications/myproject/worker.py -A args

So I set the script to /opt/applications/myproject/worker.py and the parameters to -A args.

Choose the remote interpreter we created above, and the working directory as needed, for me it is /opt/applications/myproject and for me that does the job.

Now I want to enter my container and stop the worker.py script so I can start up a debug version. Of course, if you like you can ignore running the script by default and only use the container for debugging.

I could open a ssh session to stop the script, but docker provides a useful command that will do the work for me by passing it into the environment.

Copy$> docker exec -i -t supervisorctl stop worker

As my process is named 'worker'. Note that you can restart by replacing the stop command with start.

Now, in PyCharm start a debug session with the Run Configuration created above. It should connect and start things up and give you console output in the window. Since we killed the one that Supervision originally started it is no longer connected.

This was a seat of the pants operation, so there may be errors and incorrect assumptions I didn't notice. Particularly, the PyCharm setup required a few iterations, so the order may be incorrect, try going through it again if it fails. This is a lot of stuff and easy to skip something critical.

2 of 10
4

In order to avoid any SSH overhead (which makes perfect sense with Docker), docker exec definitely seems to be the way to go.
Unfortunately I couldn't get it to work so far. It would be great if someone could fill in the blanks. Here is what I did (using PyCharm 4.0.4 and Docker 1.4.1):

  1. Create a file named python_myproject.sh containing the following:

    Copy#!/bin/bash
    docker exec -i myproject_container /path/to/containers/python2.7
    

    Note that the file's name has to begin with python otherwise PyCharm will complain.

  2. In PyCharm's settings, under Project Interpreter, add a new local interpreter. Give it the path to your python_myproject.sh file.


This is where I'm stuck. After a quite long loading time (the throbber says "Setting up library files"), a window entitled "Invalid Python SDK" appears and says:

Cannot set up a python SDK
at /path/to/python_myproject.sh.
The SDK seems invalid.

In ~/.PyCharm40/system/log/.idea:

Copy2015-02-19 17:33:30,569 [ 166966]   WARN - ution.process.OSProcessHandler - Cannot kill process tree. Trying to destroy process using Java API. Cmdline:
2015-02-19 17:34:30,628 [ 227025]   WARN - ution.process.OSProcessHandler - Cannot kill process tree. Trying to destroy process using Java API. Cmdline:
2015-02-19 17:34:30,653 [ 227050]   INFO - rains.python.sdk.PythonSdkType - 
Timed out
๐ŸŒ
Map Tech & Code
davidraleigh.github.io โ€บ 2017 โ€บ 06 โ€บ 27 โ€บ Debugging-a-Remote-Docker-Container-with-PyCharm.html
Debugging A Remote Docker Container With Pycharm | Map Tech & Code
June 27, 2017 - gcloud compute --project "blog-and-demos" ssh --zone "us-central1-f" "remote-debug-demo" cd ~/remote-debug-docker/ # copy from your docker container to your remote vm, so each new build has a copy of the helpers and your local # pycharm ide doesn't have to upload them each time you create a new image sudo docker cp temp-python-debug:/root/.pycharm_helpers ./ # upload your pycharm helpers so that you can download them to a new remote vm in the future (or some other team # can benefit from your pycharm_helpers) sudo gsutil cp -r .pycharm_helpers gs://raleigh-data/2017.1.4/ Now youโ€™ve tagged your development image with the name test-image and youโ€™ve gotten your remote-debug-docker directory setup for creating a Docker container you can ssh into.
๐ŸŒ
Medium
medium.com โ€บ @furkanpur โ€บ remote-python-debug-to-docker-container-over-ssh-by-using-pycharm-44a9b6e82206
Remote Python Debug to Docker Container over Ssh by using PyCharm | by Furkan Pur | Medium
October 8, 2019 - Letโ€™s start. Now, we need to navigate Tools > Deployment > Configuration from the menu bar. After popup opens, we need to add new server by clicking + button top left. After giving name to server, we need to select SFTP as a server type.