In Dockerfile,
ENTRYPOINT is an executed binary, which is a process.
And CMD deals with a list of arguments to go to the process, ENTRYPOINT.
(ENTRYPOINT, CMD are no case sensitive, but here upper case for readability!)
This is why you can use docker run image arguments like 'docker run image ls', because default entry point is /bin/sh -c so you can give it a linux command as argument as the subprocess of the shell.
And this is why I think the name CMD is used, not the name like args or something, because you throw an linux command to the default ENTRYPOINT process.
Imagine a docker image from a Dockerfile with ENTRYPOINT ["ls"] and CMD ["-lai", "/"].
You can override the CMD things when you use docker run:
docker run the_image -la /var
TIP:
# Don't add spare comma(,) at the end of the last double qoutes
CMD ["-lai", "/"] (O)
CMD("-lai", "/",] (X)
SUMMARY:
Make your main process to run in ENTRYPOINT.
And your arguments of the process to be in CMD.
Always think ENTRYPOINT process first(default: /bin/sh -c), CMD things are the arguments of it.
'Problem Solving' 카테고리의 다른 글
공부와 시험 사이 (2) | 2023.11.18 |
---|---|
Why a dot(.) is used at the end of docker build command? (0) | 2023.11.16 |
궁전제과 공룡알빵 (0) | 2023.11.13 |
My First Time (0) | 2023.11.08 |
초과표기법(Excess Notation) 계산 방법 (0) | 2023.11.07 |