skip to Main Content

I have this at the end of Dockerfile:

ENTRYPOINT service apache2 start

I get this logged:

 * Starting Apache httpd web server apache2 

and then my container will exit – it shouldn’t be an error, I just think the container exits because the process is a daemon. Is there a way to keep it open?

2

Answers


  1. So I can keep the container alive with:

    ENTRYPOINT service apache2 restart && /bin/bash -c "trap : TERM INT; sleep infinity & wait"
    

    but I don’t know how to get the stdout/stderr from Apache to stdout/stderr of the Docker container, anybody know? I can confirm apache is running if I keep the container alive.

    I found this example too:

    CMD ["-D", "FOREGROUND"]
    ENTRYPOINT ["/usr/sbin/httpd"]
    

    but I can’t find the path to my apache2 executable.

    Login or Signup to reply.
  2. So this should be the correct answer:

    CMD ["-D", "FOREGROUND"]
    ENTRYPOINT ["apachectl"]
    

    that is, if you installed apache with:

    RUN apt-get install -y apache2
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search