On my CentOS 7.2 box, with Docker 1.10.3, I successfully tested the following (running as root):

docker run --name usljavadoc_server -p 80:80 -p 443:443 -v /opt/app/uslJavadoc/:/var/www/html/ -d eboraas/apache

Content automatically deployed to /opt/app/uslJavadoc was servable from the apache running in the container.

So, my next step was getting this to work with systemd, so I created /etc/systemd/system/docker-usljavadoc.service with the following contents:

Description=Apache serving USL Javadoc

ExecStart=/usr/bin/docker run --name usljavadoc_server -p 80:80 -p 443:443 -v /opt/app/uslJavadoc/:/var/www/html/ -d eboraas/apache
ExecStop=/usr/bin/docker stop -t 2 usljavadoc_server
ExecStopPost=/usr/bin/docker rm -f usljavadoc_server


I manually reloaded systemd and started the service. I verified that the browser on another box could reach the apache process and get the properly served content. I then rebooted to make sure it works on reboot. Still worked.

So, I thought I was done. However, what I noticed when I looked closer is that the service successfully starts, but it exits immediately after starting, and then restarts. This is happening continuously. As it's just plain html content being served (a javadoc tree), and that the service immediately restarts, users might not even notice there is a problem, but it definitely shouldn't be doing this.

Any ideas why this "docker run" works fine from the shell, and seems to start fine from systemd, but exits immediately after a couple of seconds?

  • Have you tried to increase TimeoutStartSec or to omit the option? I could imagine 0 seconds is a little low for any service to start. Furthermore you could take a look at the log output using journalctl -u docker-usljavadoc to see if there are any hints. – dpr Dec 28 '16 at 9:25
  • 1
    I asked this first on the StackOverflow, and realized later it was more appropriate here, but I got a correct answer from that posting: stackoverflow.com/questions/41352271/… . – David M. Karr Dec 28 '16 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.