Why is PyCharm killing my subprocess.Popen?

I have a very basic subprocess.Popen command like:

cmd = ['docker', 'run', '--name=test','server']
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                     stderr=subprocess.PIPE)

When I run this in a Python script from terminal, this correctly launches the docker image and the image is persisted until I docker stop it.

  • docker build hangs in directory with many files
  • Fail when start a new container with elasticsearch 5.0
  • What is the file-system of a Docker container? On which file system does an application running inside this container runs on?
  • Docker: Run commands from multiple containers
  • Unable to access the internet from Kubernetes containers
  • Cannot access tomcat8 server running in docker container from host machine
  • However, when I run the same code from PyCharm 5, the docker image is immediately stopped when the above line is completed.

    I have verified this in the debugger (running docker ps -a shows this image immediately dies when launched from PyCharm).

    What do I have to do in order to keep my subprocess opened when running with PyCharm? Not being able to run the debugger is quite annoying.

  • Docker intermittently failing to start container
  • Python script to add data to postgres docker container runs multiple times
  • How do I limit a volume's size using the API?
  • Docker impossible setup sysctl parameter in container RHEL 6.6
  • How can I remove the Cmd entry from a Docker image configuration?
  • Docker: Could not read CA certificate: no such file or directory
  • One Solution collect form web for “Why is PyCharm killing my subprocess.Popen?”

    Are you printing out the output from the Popen call (stdout and stderr)? What does it say?

    Launching subprocesses from an IDE can be tricky, because certain environment variables (like PATH) may not be set in the same way as your shell.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.