RUN wget https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb RUN dpkg -i dumb-init_*.deb
RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 RUN chmod +x /usr/local/bin/dumb-init
pip install dumb-init
entrypoint
固定使用
dumb-init
为容器运行的第一个进程。
# Runs "/usr/bin/dumb-init -- /my/script --with --args" ENTRYPOINT ["/usr/bin/dumb-init", "--"]
ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/usr/local/bin/docker-entrypoint.sh"]
/usr/bin/dumb-init
为PID为1的进程,
/usr/local/bin/docker-entrypoint.sh
作为其子进程,可以正常收到进程信号。但是
/usr/local/bin/docker-entrypoint.sh
中如果再运行子进程,如运行一个java进程,那java进程中就获取不到进程信号,此时可以加一个
exec
来提升子进程到PID进程下。
/usr/local/bin/docker-entrypoint.sh
中:
#!/bin/bash echo "Hello world!" java hello.jar
/dumb-init +--- /usr/bin/dumb-init +--- /bin/bash +--- java ... dumb-init,1 -- /usr/local/bin/docker-entrypoint.sh └─java,7 -Xmx64m -Xms16m -Xmn8m -Xss1m -XX:ReservedCodeCacheSize=5m -XX:NewRatio=3 -jar /usr/local/agent/agent-1.0.1.jar WEX5-JAVA-IDE
#!/bin/bash echo "Hello world!" exec java hello.jar
+--- java ...
原文发布时间为:2017-04-26 本文作者:史绍虎 本文来自云栖社区合作伙伴Dockerone.io,了解相关信息可以关注Dockerone.io。 原文标题:
Dumb-Init进程信号处理