Docker Community Forums

Share and learn in the Docker community.

Jobs are killed after exit the interactive mode of docker container

Hi, All,

I am using docker container in my work. I build the docker image that contains gpgpusim(one gpu simulator) and pull it in my server. I run the docker container and launch the benchmarks that I need. After this, I use ctrl+p and ctrl+q to exit the interactive mode and keep the container running in the background. But when I re-enter the container again. I found that my benchmarks have been killed immediately when I detached from the interactive mode. I tried to check the status of the container and found that it is still running in the background when I exit the interactive mode. But my jobs are always killed once I detached from the container terminal.

Will anyone have same experience and share your solution?

Best regards.
Shougang

Using container in interactive mode sounds weird to me. No one using docker seriously is doing anything in a terminal of the container, unless he/she is trying to troubleshot something. Put your stuff in a Dockerfile, write an entrypoint script that starts your main application and let automation do it’s magic.

Your use case sounds like docker might not be the right technological choice and that it might be better suited for traditional vms?

[sven@t440s docker] docker run -d -name test-exec busybox top Warning: '-name' is deprecated, it will be replaced by '--name' soon. See usage. 0daecd23a78f05990466c9f7d1094c737771a0cc15142588bb57ebd6b7f99c5f [sven@t440s docker] docker exec -it test-exec sh
/ # ps
PID USER COMMAND
1 root top
7 root sh
13 root ps
/ # kill 7
/ # ps
PID USER COMMAND
1 root top
7 root sh
14 root ps
/ # kill -9 7
[sven@t440s docker] docker exec -it test-exec ps aux PID USER COMMAND 1 root top 15 root ps aux [sven@t440s docker] docker version
Client version: 1.3.1
Client API version: 1.15
Go version (client): go1.3.3
Git commit (client): 4e9bbfa
OS/Arch (client): linux/amd64
Server version: 1.3.1
Server API version: 1.15
Go version (server): go1.3.3
Git commit (server): 4e9bbfa
[sven@t440s docker]$
and the non-containerised version works the same:

[sven@t440s docker] sh sh-4.2 ps
PID TTY TIME CMD
11920 pts/3 00:00:00 bash
12090 pts/3 00:00:00 sh
12091 pts/3 00:00:00 ps
sh-4.2$ kill 12090
sh-4.2$
sh-4.2$ ps
PID TTY TIME CMD
11920 pts/3 00:00:00 bash
12090 pts/3 00:00:00 sh
12092 pts/3 00:00:00 ps
sh-4.2$ kill -HUP 12090
Hangup