在通过docker commit制作镜像的时候,如果是直接commit通常来说是没有entrypoint的,这在k8s等场景下会带来一点麻烦。
要解决这个问题也很简单,有以下两个办法可以实现
编写dockerfile实现
假设我们有一个container = 93c11d3b5700
$docker commit 93c11d3b5700 test:no_entrypoint
编写dockerfile
from test:no_entrypoint
entrypoint bash /root/start.sh
在commit命令中集成
$docker commit --change='ENTRYPOINT bash /root/start.sh' 93c11d3b5700 test:with_entrypoint
查看容器的entrypoint
$docker inspect test:with_entrypoint | grep Entrypoint -A 5
"Entrypoint": [
"/bin/sh",
"-c",
"bash /root/start.sh"
],