node.js - 使用主管在 docker 中运行 Node 和 nginx

标签 node.js docker nginx supervisord

我正在尝试在 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/

相关文章:

node.js - 如何通过 https 在生产服务器上使用 Laravel Echo

database - Node.js 数据库批量插入与一次插入一个

javascript - 在 setTimeout 内调用函数

javascript - 有人可以帮我从我的 Db Sequelize 中删除记录吗?

node.js - 将 Nodejs 与 IIS 结合使用,以使用 Express 实现 REST 服务

angular - 如何在 Nginx 容器内路由 Angular 应用程序?

docker - 在 Docker 中执行时,无法在 Inno Setup 预处理器中获取环境变量

docker - 使用Docker的Virtualbox端口转发

rest - 从网站调用不安全的端点在 HTTPS 下运行 - nginx

url-rewriting - 使用代理传递的Nginx重写规则