Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We can interact with docker using

  • docker run demo hostname
    • overrides the CMD value in the Dockerfile
    • returns the host's name
  • docker run demo ls -al
    • overrides the CMD values in the Dockerfile
    • lists all the files in the landing directory, notice the param "-al" is passed to the "ls" command
  • docker run --entrypoint hostname demo
    • returns the host's name
  • docker run --entrypoint demo -al
    • lists all the files in the landing directory, notice the param "-al" is passed to the "ls" command

Notice the subtle difference in how parameters to the command you wish to execute are passed.  With ENTRYPOINT, the command is specified after the --entrypoint switch, but params to the command are passed after the image name.

Combining CMD with ENTRYPOINT

Code Block
languagebash
titledocker file
FROM ubuntu:trusty
ENTRYPOINT ["/bin/ping", "-c", "3"]
CMD ["localhost"]

When ENTRYPOINT is combined with CMD, the CMD values are appended to the ENTRYPOINT values, so the command that is executed is "/bin/ping -c 3 localhost"