Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running/Debugging Pycharm Python Scripts with remote Docker Machine

I'm using a remote workstation (Ubunutu 18.04) with a GPU via Docker Machine. With PyCharm Professional 2018.1.4 I can connect remotely to the workstation and create/start containers, connect to them and attach a terminal.

The problem occurs when I try to run a python script via docker compose with PyCharm. I get the error:

python: can't open file '/opt/project/testing.py': [Errno 2] No such file or directory

I have the following docker-compose file:

version: '3'
services:
  densepose:
    build: Dockerfile
    image: densepose
    volumes:
      - ./:/opt/project # I have tried adding and removing this to no avail
      - ./included_files:/included_files
      - ./output:/output

And I am using the Dockerfile from here

I have tried using both Ubuntu 17.10 and Windows 10 with PyCharm to connect to the remote station to do this but I receive the same error.

Edit:
After more digging it seems to be related to PyCharm copying files pr-emptively to the remote docker-machine. It should be using docker-machine scp but I'm not sure yet.

like image 778
TheFamousDirector Avatar asked Jul 04 '18 12:07

TheFamousDirector


People also ask

Can I use PyCharm with Docker?

PyCharm integration with Docker allows you to run your applications in the variously configured development environments deployed in Docker containers.

How do I connect to a remote server with PyCharm?

Connect to a remote server and open the remote project Ensure you have the Remote Development Gateway plugin enabled. On the PyCharm welcome screen, select Remote Development. In the Run the IDE Remotely section, click SSH Connection.

How do I run a Docker image in PyCharm?

In the Services tool window, select the Images node. Select the Docker registry and specify the repository and tag (name and version of the image, for example, tomcat:latest . Press Ctrl+Enter to run docker pull. Specify the image as in the Docker CLI, for example: ubuntu:20.04 .


1 Answers

Paths mappings don't deploy your files to the remote server. You need to create a remote server configuration and upload your files to the remote machine.

Pycharm has a tool for deployment as described here

like image 152
TheFamousDirector Avatar answered Oct 05 '22 00:10

TheFamousDirector