[英]docker container exits immediately after run [mosquitto broken container]
hello i have a problem with docker, recently i make dockerfile for create a image of "mosquitto-mqtt" to make my own broken mqtt with ssl protection. 您好,我对docker有问题,最近我制作了dockerfile,用于创建“ mosquitto-mqtt”映像,以使用ssl保护制作自己的损坏的mqtt。 i build dockerfile all is good, i don't have a problem but if i run a new container with " docker run -itd --name broken ce69ee4b2f4e" a container run and exit automaticly, and if a check log all is good "[ ok .] Starting network daemon:: mosquitto.".
我构建dockerfile一切都很好,但是我没有问题,但是如果我运行带有“ docker run -itd --name broken ce69ee4b2f4e”的新容器,则容器会自动运行并退出,如果检查日志一切正常,[[ ok。]启动网络守护程序:: mosquitto。”。 i don't have why ?
我没有为什么? check my dockerfile.
检查我的dockerfile。 i need help to solve it, thanks you
我需要帮助解决它,谢谢
#Download base image debian
FROM debian:latest
#Update system
RUN apt-get update -y
#Install Wget and gnup2
RUN apt-get install wget -y && apt-get install gnupg2 -y
#Download and add key
RUN wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
RUN apt-key add mosquitto-repo.gpg.key
RUN rm mosquitto-repo.gpg.key
## append apt mirror for debian
RUN echo "# mirror" >> /etc/apt/source.list
RUN echo "deb http://repo.mosquitto.org/debian stretch main" >> /etc/apt/source.list
#Update and upgrade system
RUN apt-get update -y && apt-get upgrade -y
#install mosquitto
RUN apt-get install mosquitto -y
#Copy file configuration
COPY mosquitto.conf /etc/mosquitto
#Copy certificate folder
COPY certs/mosquitto-ca.crt /etc/mosquitto/certs
COPY certs/mosquitto-server.crt /etc/mosquitto/certs
COPY certs/mosquitto-server.key /etc/mosquitto/certs
#Run command
ENTRYPOINT ["/etc/init.d/mosquitto", "start"]
log print 日志打印
[ ok .] Starting network daemon:: mosquitto.
docker ps -a 泊坞窗ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d00bd23ae2d6 ce69ee4b2f4e "/etc/init.d/mosquit…" 9 minutes ago Exited (0) 9 minutes ago broken
Containers are a wrapper around a process, and when that process exits, the container exits. 容器是流程的包装,当该流程退出时,容器退出。 In this case:
在这种情况下:
ENTRYPOINT ["/etc/init.d/mosquitto", "start"]
That process is /etc/init.d/mosquitto
which almost certainly runs, spawns a daemon in the background, and exits (standard for anything in init.d). 该进程是
/etc/init.d/mosquitto
,几乎可以确定该进程运行,在后台生成守护程序并退出(init.d中任何内容的标准设置)。 You should instead run mosquito directly with foreground options if available. 如果可用,您应该直接使用前景选项运行蚊子。
If that's some possible, something like supervisord would be a less than optimal fallback, with the ability to watch a background daemon. 如果可能的话,像supervisor这样的东西将不是最佳的后备,并且具有观看后台守护程序的能力。
And if neither of those work, you can run your command from a script that ends with a tail -f /dev/null
, but that would be the worst option since you ignore any errors. 而且,如果这些都不起作用,则可以从以
tail -f /dev/null
结尾的脚本中运行命令,但这将是最糟糕的选择,因为您会忽略任何错误。
it works ! 有用 ! i found the solution, it just need to add "-C" on command and specify directory
我找到了解决方案,只需要在命令中添加“ -C”并指定目录
this is a good method 这是一个好方法
ENTRYPOINT ["mosquitto", "-c", "/etc/mosquitto/mosquitto.conf"]
thanks all to help Me! 谢谢大家对我的帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.