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,

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.

  • Debugging a bash script in a container gives a process on the host?
  • $(uname -a) returning the same in docker host or any docker container
  • Error “Failed to OpenForBackup failed in Win32” when pulling microsoft/nanoserver container
  • Can't start mongo with docker command, but can with /bin/bash inside container (with data volume)
  • Linked Docker Containers with Mesos/Marathon
  • Starting mongo through docker on a Synology NAS
  • 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.

  • Why can't Java find a class from a jar file?
  • RabbitMQ, docker, single queue, multiple consumers
  • CI and CD implementation issues
  • Run a new container based on currently running container
  • How to restart php-fpm inside a docker container?
  • Clarify docker-tag and docker-push command
  • 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.