4

I am attempting to dockerize a GUI app and have had some success. If I build the dockerfile into an image and then perform a docker run --name testcontainer testimage it appears that the process begins but the abruptly stops. I then check the container with docker ps to confirm no containers are running. Then I check docker ps -a and can see that it exited with status code exit(0). Then if I run the command docker start testcontainer, it appears to start the ENTRYPOINT command again, but this time it is able to continue and the GUI pops up.

My best guess is that I think that when I run the docker run command, the process begins but might be forked into a background process, causing the container to exit since the foreground process has ended. Although that could be way off because you would think the docker start command would result in the same outcome. I was thinking of trying to force the process to stay in the foreground, but do not know how to do that. Any suggestions?

UPDATE: I editted my Dockerfile to use supervisord to manage the starting of the GUI app. Now my docker run command will start supervisor, which will start my GUI app, and it works. Some things to note about this are that supervisor shows:
INFO spawned: myguiapp with pid 7
INFO success: myguiapp entered RUNNING state
INFO: exited: myguiapp (exit status 0; expected)
Supervisor and the container are still running at this point, which seems to indicate that the main process kicks off a child process. Since supervisor is still running, my container stays up and the GUI app does show up and I can use it. When I close the GUI, supervisor reports:
CRIT reaped unknown pid 93
Supervisor remains running, causing the container NOT to close. So I have to CTRL-C to kill supervisor. I'd rather not use supervisor, but if I need to, I would like for supervisor to close itself gracefully when that child process ends. If I could figure out how to get my container or supervisor to track child processes of the main process, then I think this would be solved.

codenaugh
  • 857
  • 2
  • 12
  • 27
  • how does your dockerfile and start command look like? if your start command exits, then your containers exits too. So starting your process in the foreground sounds like a good idea. – christian Aug 17 '15 at 19:53
  • Sorry, I don't understand what you mean. My docker start command works fine after the run command exits. my ENTRYPOINT command is just the CLI path to the executable for the GUI app I'm dockerizing. – codenaugh Aug 17 '15 at 19:56

1 Answers1

2

The first issue is probably because your application requires a tty and you are not allocating a pseudo tty. Try running your container like this:

docker run -t --name testcontainer testimage

When you do a docker start the second time around it somehow allocates the pseudo-tty and the process keeps on running. I tried it myself. I couldn't find this info anywhere in the Docker docs though.

Also, if your UI is interactive you would want:

docker run -t -i --name testcontainer testimage
Rico
  • 58,485
  • 12
  • 111
  • 141
  • 1
    I would also add `-i' for interactive, for a GUI application – user2915097 Aug 17 '15 at 21:01
  • the GUI is interactive but does not seem to require -i. That being said, I have tried -it as well as each flag individually with no changes in outcome. – codenaugh Aug 18 '15 at 00:28
  • @CommanderCody can you post your Dockerfile? as well as what type of GUI application ? What language? What Library ? – Rico Aug 18 '15 at 00:44
  • I cannot, as you wouldn't have access to grab the install files anyway (it's a work project). Just know that it is a big java based application. – codenaugh Aug 18 '15 at 01:00