在通過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"
],