title: Pycharm use Docker Container Python as Remote Interpreter
body: <p>I am trying to use the python in a docker container on a remote machine as the interpreter in Pycharm. Since that is a mouthful, here is a diagram:</p>
  
  <p><a href="https://i.stack.imgur.com/jck3L.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jck3L.png" alt="enter image description here"></a></p>
  
  <p>There is a Jupyter Notebook running in the container, which I am able to connect to through my local browser (although this is just for testing the connection). The command I am using to launch the Docker container is </p>
  
  <pre><code>docker run --runtime=nvidia -it --rm --shm-size=2g -v /home/timo/storage:/storage -v /etc/passwd:/etc/passwd -v /etc/group:/etc/group --ulimit memlock=-1 -p 8888:8888 -p 7722:22 --ipc=host latest:latest
  </code></pre>
  
  <p>I can forward the port 8888 which the Jupyter notebook is running on with <code>ssh -L 8888:0.0.0.0:8888 BBB.BBB.BBB.BBB</code> and thus use it on the local machine. But I don't much like using Jupyter for developing and would like to use the Python interpreter in the Docker Container in Pycharm.</p>
  
  <p>When I select "Add Python Interpreter" in Pycharm, I get the following options:</p>
  
  <p><a href="https://i.stack.imgur.com/MoZpW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MoZpW.png" alt="enter image description here"></a></p>
  
  <p>The <a href="https://www.jetbrains.com/help/pycharm/using-docker-as-a-remote-interpreter.html" rel="noreferrer">documentation</a> for Pycharm suggests using the "Add Python Interpreter/Docker" tool which looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/MTFdg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MTFdg.png" alt="enter image description here"></a></p>
  
  <p>However the documentation doesn't say how to set up the Docker container and the connections if the Docker is on a remote machine.</p>
  
  <p>So my questions are: should I use a Unix or a TCP socket to connect to my remote docker? Or should I somehow forward all the relevant ports from the container and use the "SSH Interpreter" option? And if so, how do I set this all up? Am I setting up my Docker Container properly in the first place?</p>
  
  <p>I think I have trawled through <em>every</em> forum and online resource, over the last two days, but have not come any closer to getting this to work. I have also tried to get this to work in Spyder, but to no avail either. So any advice is very appreciated!</p>
  
  <p>Many thanks!</p>