Search code examples
apachedockersupervisordcoreos

Can't start apache with supervisord from a Docker container


I'm running a Docker container with CoreOS which uses Debian latest as a base and has various packages installed including supervisor and apache2. I can start and successfully run apache using the following command:

# /usr/bin/pidproxy /var/run/apache2.pid /bin/bash -c "source /etc/apache2/envvars && /usr/sbin/apache2 -DFOREGROUND -k start"

However, when I stick this command in a supervisor config file:

[program:apache2]
command=/usr/bin/pidproxy /var/run/apache2.pid /bin/bash -c "source /etc/apache2/envvars && /usr/sbin/apache2 -DFOREGROUND -k start"
redirect_stderr=true

and do this:

# supervisorctl start apache2

I get back this response:

apache2: ERROR (abnormal termination)

Looking at the supervisor process log file I see the help output from the apache2 command, as if it had been called like so apache2 -h. I have no idea why a command which runs when executed on the command line as root (ssh into the container) would not work when verbatim executed by supervisorctl (run as root).

Any point in the right direction would be greatly appreciated.


Solution

  • Not really sure why, but adding quotes to my option values seems to have done the trick, and allowed me to use apachectl. Must be something with the context in which the command is interpreted, whatever supervisor is doing vs input from a bash prompt. Here's my working config file:

    [program:apache2]
    command=apachectl -D "FOREGROUND" -k start
    redirect_stderr=true