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.

  • Best way to pass config file during Docker build
  • How to pass an ARG to a Dockerfile in a docker-compose.yml
  • Using AWS Simple Workflow to start a docker container
  • How to run cronjob in docker, and how to see the result?
  • Exposing Docker application to host
  • Getting access to GPU on Docker on Windows 10
  • 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.

  • need for Node.js docker image that run the app when start
  • Different hashes while pulling from hub and pushing to registry
  • Ignore directories with .dockerignore or volume?
  • Docker GitHub Automated Build Arguments
  • Why does docker overwrite everything I've installed?
  • connect a password of mssql server to other services in using docker
  • 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.