Reputation: 2202
I'm trying to setup node and nginx inside my docker container, using supervisor to start and monitor both processes. I have a supervisor conf file that starts nginx and node.
The problem is that when I try to use supervisorctl to access the services they are not found. So I think I must be doing something wrong.
supervisor.conf
[supervisord]
nodaemon=true
[program:nodeServer]
directory=/app/backend
command=/nodejs/bin/node app.js
autostart=true
autorestart=unexpected
user=www-app
startsecs=10
stdout_logfile=/var/log/repositive.io/supervisor.log
redirect_stderr=true
[program:nginx]
command=/usr/sbin/nginx
stdout_events_enabled=true
stderr_events_enabled=true
dockerfile
FROM google/debian:wheezy
# update and install nginx and supervisor
RUN apt-get update -y && \
apt-get install --no-install-recommends -y -q \
curl python build-essential git ca-certificates nginx-extras supervisor
# install node
RUN mkdir /nodejs && \
curl http://nodejs.org/dist/v0.10.32/node-v0.10.32-linux-x64.tar.gz | \
tar xvzf - -C /nodejs --strip-components=1
ENV PATH $PATH:/nodejs/bin
# setup db
RUN apt-get install -y postgresql
USER postgres
RUN /etc/init.d/postgresql start && \
createuser repositive -S -D -R && \
createdb --owner=repositive --port=5432 repositive && \
createdb --owner=repositive --port=5432 repositive-testing
# init app
USER root
RUN mkdir -p /var/www/repositive.io
RUN mkdir -p /var/log/repositive.io
RUN chown -R www-data:www-data /var/www/repositive.io
WORKDIR /app
ONBUILD ADD nginx.conf /etc/nginx/sites-available/default
ONBUILD ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
ONBUILD ADD ../ /app
ONBUILD RUN npm install
ENV NODE_ENV production
EXPOSE 80
CMD ["/usr/bin/supervisord"]
Now I try to access one of the services by building the image than running running it in interactive mode:
sudo docker run -t -i timrich/api.repositive.io:V0.0.1 /bin/bash
root@b16b20f8f1b4:/app# /usr/bin/supervisord
root@b16b20f8f1b4:/app# supervisorctl status nginx
No such process nginx
But none of the supervisor jobs are found
Upvotes: 1
Views: 5246
Reputation: 2751
Have you considered running the two services in separate containers?
Upvotes: 2
Reputation: 576
When you run your Docker container with docker run ... [command] you overwrite the default command which is specified in your dockerfile (supervisord) see here. Try starting it without the command option, in your case "/bin/bash". This means in your case you stared the bash instead of supervisord, which means that no processes from supervisord are started.
If you want to check if everything works you can use docker logs or docker exec.
Upvotes: 2