无法在/etc/supervisor/conf.d/ docker文件中复制.conf

时间:2020-07-30 20:34:55

标签: docker ubuntu

我正在尝试在docker文件中安装超级用户,如下所示:

FROM ubuntu:18.04 
RUN \
  apt-get update && \
  apt-get install -y supervisor && \
  rm -rf /var/lib/apt/lists/* && \
  sed -i 's/^\(\[supervisord\]\)$/\1\nnodaemon=true/' /etc/supervisor/supervisord.conf
VOLUME ["/etc/supervisor/conf.d"]
WORKDIR /etc/supervisor/conf.d
EXPOSE 80 443 5002 5005 22
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]

有效。但是一旦添加以下内容:

COPY AppSupervisor.conf /etc/supervisor/conf.d/

之前

EXPOSE 80 443 5002 5005 22

然后docker映像构建和docker run成功,但是我看不到docker ps的任何conatiner

1 个答案:

答案 0 :(得分:0)

最有可能在超级用户配置中出现错误,导致退出容器。

最好在前景docker run -it --rm my_image中运行容器或检查容器日志,您会发现docker ps -adocker logs container_name

出于测试目的,需要与以下示例配合使用的更改

RUN apt-get update && apt-get install nginx -y
WORKDIR /etc/supervisor/conf.d
COPY supervisor.conf .

这是将启动Nginx的工作示例。

[program:nginx]
command=nginx -g 'daemon off;'
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
autostart=true
priority=1
autorestart=true
exitcodes=0 , 4
startretries = 20

这应该可行,因此请相应地更正配置文件。

通过在前台运行容器,您将看到

2020-07-31 01:15:09,339 CRIT Supervisor running as root (no user in config file)
2020-07-31 01:15:09,339 INFO Included extra file "/etc/supervisor/conf.d/supervisor.conf" during parsing
2020-07-31 01:15:09,347 INFO RPC interface 'supervisor' initialized
2020-07-31 01:15:09,347 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2020-07-31 01:15:09,348 INFO supervisord started with pid 1
2020-07-31 01:15:10,351 INFO spawned: 'nginx' with pid 9
2020-07-31 01:15:11,398 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)