English 中文(简体)
如何在Docker集装箱内操作Nginx而不停泊?
原标题:How to run Nginx within a Docker container without halting?

我在Docker集装箱上安装了Nginx,并试图将其照样操作:

docker run -i -t -p 80:80 mydockerimage /usr/sbin/nginx

问题是,Nginx公司的工作方式是,最初的过程立即导致Nginx总公司和一些工人,然后放弃。 由于Docker只看PID原指挥部,该集装箱随后停下来。

我如何阻止集装箱停泊? 我需要能够告诉它要遵守第一个儿童进程,或停止Nginx最初的退出进程。

最佳回答

nginx, 如同所有行为良好的方案一样,可以不进行自我垄断。

http://wiki.nginx.org/CoreModule” rel=“noreferer” http://wiki.nginx.org/CoreModule。

问题回答

为了扩大对Charles Duffy的回答,Nginx使用daemon off指令在地下操作。 如果在配置档案中说明这一点不方便,我们就可以直接将其具体指明在指挥线上。 这使得通过改变指挥线的杠杆,很容易以 de(地下)的方式运行,并直接转向生产模式(后方)。

1. 草原:

nginx -g  daemon off; 

具有以下背景:

nginx

在约翰的答复中扩大,您也可使用DockerfileCMD。 指挥(如果你想要在没有额外动力的情况下自行启动)

CMD ["nginx", "-g", "daemon off;"]

将这一指挥权添加到Dockerfile,可能会使其失去作用:

RUN echo "daemon off;" >> /etc/nginx/nginx.conf

加上Tomer和Charles的答复,

2. 采用切入点在多克集装箱的地面上操作原gin子:

ENTRYPOINT nginx -g  daemon off;  

并非直接相关,而是由多个指挥机关代行:

ENTRYPOINT /bin/bash -x /myscripts/myscript.sh && nginx -g  daemon off;  

For all who come here trying to run a nginx image in a docker container, that will run as a service

既然没有完整的Dockerfile,这里是我解决问题的全文Dockerfile

尼斯和工作。 感谢这里的所有答复,以便解决最后的原始问题。

FROM ubuntu:18.04
MAINTAINER stackoverfloguy "stackoverfloguy@foo.com"
RUN apt-get update -y
RUN apt-get install net-tools nginx ufw sudo -y
RUN adduser --disabled-password --gecos    docker
RUN adduser docker sudo
RUN echo  %sudo ALL=(ALL) NOPASSWD:ALL  >> /etc/sudoers
USER docker
RUN sudo ufw default allow incoming
RUN sudo rm /etc/nginx/nginx.conf
RUN sudo rm /etc/nginx/sites-available/default
RUN sudo rm /var/www/html/index.nginx-debian.html
VOLUME /var/log
VOLUME /usr/share/nginx/html
VOLUME /etc/nginx
VOLUME /var/run
COPY conf/nginx.conf /etc/nginx/nginx.conf
COPY content/* /var/www/html/
COPY Dockerfile /var/www/html
COPY start.sh /etc/nginx/start.sh
RUN sudo chmod +x /etc/nginx/start.sh
RUN sudo chmod -R 777 /var/www/html
EXPOSE 80
EXPOSE 443
ENTRYPOINT sudo nginx -c /etc/nginx/nginx.conf -g  daemon off; 

并且用:

docker run -p 80:80 -p 443:443 -dit

在杜克·布赖恩官方国家地理信息小组影像的正式照会中,该声明:

If you add a custom CMD in the Dockerfile, be sure to include -g daemon off; in the CMD in order for nginx to stay in the foreground, so that Docker can track the process properly (otherwise your container will stop immediately after starting)!

这使我想去除《千年发展目标》[]可能首先阻止这一问题发生吗?





相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签