0

I have volume binding set up mapping a few different paths to my Docker container. I have Docker plugin set up in Pycharm Pro and the container's interpreter set as my Python interpreter. I can deploy my python scripts using the docker interpreter without any trouble (in terms of packages and dependencies created on the docker image).

However, when deploying scripts and trying to access files stored on my local machine via volume bindings, it doesn't find them. When I open an interactive debug shell in pycharm and run os.path.exist, it returns True for the parent paths of the volume bindings (within the container) but returns False for any files or directories that are supposed to be mapped there from my local machine.

This is strange because the volume bindings are active, I have verified that in multiple ways:

  1. I can see Pycharm's Docker tool window listing the bindings correctly

  2. I can see the mapped files showing up in the container when checking from the terminal.

  3. I can also open a terminal in my container and launch python shell and run os.path.exist this also returns True confirming that the directories are mapped and found under the paths I specified in my volume bindings.

Why can't I access my volume bindings when deploying python scripts through Pycharm's Docker interpreter - even though the scripts run fine otherwise?

System information:

Pycharm version: Pycharm Professional 2019.1.2

Docker version: 2.0.0.3

Local machine OS: macOS 10.13.4 High Sierra

Docker OS: Ubuntu 16.04

New contributor
Kristof is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
0

It turns out Docker plugin for Pycharm does not attach to existing running containers when I deploy a script (even though a in a somewhat misleading way it has a Docker tool window that lists running containers and shows their volume bindings as if those were used for deployment). Instead, it launches a new container from the image each time you deploy a script. So if you want to bind volumes to these temporary container instances each time you launch the script, you need to navigate to Run/Edit Configurations and set for each script the volume bindings, under the 'Docker Container settings'. I did not know this was the volume bindings used for deployment rather than the ones set in the Docker tool window on the running container.

New contributor
Kristof is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

Kristof is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.