我正在尝试在 docker 容器内设置 Node 和 nginx,使用主管来启动和监视这两个进程。我有一个启动 nginx 和 node 的主管 conf 文件。
问题是当我尝试使用supervisorctl 访问服务时找不到它们。所以我想我一定做错了什么。
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
docker 文件
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"]
现在我尝试通过构建镜像来访问其中一项服务,而不是以交互模式运行它:
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
但是没有找到主管职位
最佳答案
您是否考虑过在单独的容器中运行这两个服务?
关于node.js - 使用主管在 docker 中运行 Node 和 nginx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27249380/