常常忘記,很粗略的筆記一下
經同事說明
根據:
- https://stackoverflow.com/questions/21553353/what-is-the-difference-between-cmd-and-entrypoint-in-a-dockerfile
- https://docs.docker.com/v17.09/engine/reference/builder/
CMD
- The CMD specifies arguments that will be fed to the ENTRYPOINT.
- There can only be one CMD instruction in a Dockerfile. If you list more than one CMD then only the last CMD will take effect.
ENTRYPOINT
- The ENTRYPOINT specifies a command that will always be executed when the container starts.
- An ENTRYPOINT allows you to configure a container that will run as an executable.
應該是這樣子:
- 一個 Dockerfile 內只能有一個
CMD
,如果有多,生效會是最後一個CMD
CMD
會被當成ENTRYPOINT
參數ENTRYPOINT
預設是/bin/sh -c
CMD
沒有預設值
初步的感覺有點像
今天 Dockerfile 只有
1 | FROM ubuntu |
1 | ⚡ docker build -t ajdfajdfl/test-entrypoint . |
也就是
預設會是這樣 ENTRYPOINT
+ CMD
: /bin/sh -c "ls"