码头工人-码头工人运行-总是重新启动实际上是做什么的? [英] Docker - what does `docker run --restart always` actually do?
本文介绍了码头工人-码头工人运行-总是重新启动实际上是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尽管--restart标志看起来很简单明了,但是在尝试它时我提出了许多问题:
Although it seems like the --restart flag is simple and straightforward, I came up with a number of questions when experimenting with it:
- 关于
ENTRYPOINT
定义-重新启动期间实际定义的语义是什么? - 如果我
exec
进入容器(我在DDC上)并杀死-9进程,它将重新启动,但是如果我执行docker kill
则不会.为什么? - 重新启动如何与共享数据容器/命名卷交互?
- With respect to
ENTRYPOINT
definitions - what are the actual defined semantics during restart? - If I
exec
into the container (I am on a DDC) and kill -9 the process, it restarts, but if I dodocker kill
it does not. Why? - How does restart interact with Shared Data Containers / Named Volumes?
推荐答案
今天我有一些时间可以调试更多->因为我使用的是官方"码头工人镜像,所以几乎看不到发生了什么.为了解决这个问题,我扩展了官方形象并调用了我自己的入口点.Dockerfile:
I had some time to debug this more today -> because I was using an 'official' docker image I had little to no visibility into what was occurring. To resolve this, I extended the official image and invoked my own entrypoint. The Dockerfile:
FROM officialImage:version
ENV envOne=value1 \
envTwo=value2
COPY wrapper-entrypoint.sh /
ENTRYPOINT ["/wrapper-entrypoint.sh"]
然后我在 wrapper-entrypoint.sh
脚本中进行了设置-x"并调用了原始脚本:
Then I did a 'set -x' in the wrapper-entrypoint.sh
script and invoked the original:
#!/bin/bash
set -x
echo "Be pedantic: all args passed: $@"
bash -x ./original-entrypoint.sh "$@"
由此我发现:
- 重新启动会使用原始参数调用原始的
ENTRYPOINT
.我使用的官方图片检测到它已经初始化,因此采取了不同的行动.这就是为什么我对语义感到困惑.使用-x
可以查看实际情况. - 我仍然不知道为什么
docker kill
会停止重新启动,但这就是我所看到的-至少在Docker Data Center上如此. - 我不认为共享数据量会以任何方式影响此,请根据重新启动时的条件保存给定
ENTRYPOINT
脚本可能采取的操作.
- Restart does call the original
ENTRYPOINT
with the original arguments. The official image I used detected it had already initialized and thus acted differently. This is why I was confused over the semantics. Using-x
allowed me to see what was really happening. - I still don't know why
docker kill
stops the restart, but that is what I see - at least on Docker Data Center. - I don't believe Shared Data Volumes affect this in any way, SAVE for the actions a given
ENTRYPOINT
script might take based upon it's condition at the time of the restart.
这篇关于码头工人-码头工人运行-总是重新启动实际上是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文