Problem scenario
You want to use the ENTRYPOINT and CMD keywords in a Dockerfile. You know that the value of CMD amounts to a parameter for the ENTRYPOINT value which is executed. You want to verify that the value of ENDPOINT is used in an execution. You want the Dockerfile to be simple to illustrate these reserved words. What do you do?
Solution
Prerequisite
Install Docker. See this posting if you need directions.
Procedures
1. Create a file called Dockerfile. Have these three lines be the content:
FROM ubuntu:latest
ENTRYPOINT ["echo"]
CMD ["parameter1 parameter2"]
2. Run this command: docker build .
3. The above command should say something like this: "Successfully build abcd1234"
The "abcd1234" is the image ID. Run this next command, but replace "abcd1234" with the image ID that you just created:
docker run abcd1234
# This command above should print "parameter1 parameter2".
You are done. That should demonstrate how ENTRYPOINT values use the CMD values as parameters. In the Dockerfile when you use "docker run" with an image that was the result of a Dockerfile with ENTRYPOINT and CMD stanzas, there will be execution of ENTRYPOINT with one or more additional parameters if CMD is also used.