Docker Community Forums

Share and learn in the Docker community.

Starting docker container from python script

docker

(Larrymartell59) #1

I want to start my container from a python script. I am doing that using subprocess.Popen. It works fine, but when the python script returns, the terminal settings of my shell are messed up. Nothing is echoed and return doesn’t cause a newline. I can fix this with ‘tset’ in the terminal, but I don’t want to require that. Has anyone seen and solved this issue?


(David Maze) #2

I docker run things in Python build scripts all the time and don’t have issues like what you describe. Can you give more details, like which containers you’re running and what arguments you’ve giving to docker run?


(Larrymartell59) #3

cmd = ['sudo', 'docker', 'run', '-t', '-i', 'elucidbio/capdata:v2', 'bash' ] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

I have tried replacing the bash with an infinite loop and using nohup, but the same thing happened.


(Rizwan2k10) #4

remove interactive or -i option, You should be able to run in non interactive mode