Starting docker container from python script

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?

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?

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.

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