【发布时间】:2021-11-28 06:52:24
【问题描述】:
我有以下 Dockerfile,对 Nginx 服务器进行了一些自定义。我使用docker build -t nginx-custom:1.21.1 . 命令构建图像,完成时没有错误。但是,当我想使用docker run -it -d nginx-custom:1.21.1 /bin/bash 命令从此图像创建容器时,也不会出现任何错误。但是当我使用docker exec 命令进入容器并使用ps -ef 检查正在运行的进程时,结果只包含bash 进程。
FROM nginx:1.21.1 AS nginx-base
RUN set -x \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y man nano procps ca-certificates wget gnupg gnupg2 iputils-ping net-tools supervisor \
&& apt-get clean autoclean \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
EXPOSE 80 443
WORKDIR /var/www
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["service supervisor restart"]
FROM nginx-base AS nginx-config
# Replace the original Nginx config file
COPY config/nginx.conf /etc/nginx/nginx.conf
# Test HTML file
COPY scripts/index.html /var/www/html/index.html
在一些失败之后,我创建了一个包含以下内容的 compose 文件并运行了下一个命令:docker-compose up -d --build 然后一切正常。所有必要的进程都在运行。
version: '3.8'
services:
nginx-custom:
tty: true
build:
context: .
dockerfile: Dockerfile
image: nginx-custom:1.21.1
container_name: nginx-custom
networks:
devnet:
ipv4_address: 172.18.0.4
restart: unless-stopped
networks:
devnet:
external: true
有人知道为什么主管只能这样工作吗?
【问题讨论】:
标签: docker nginx docker-compose supervisord