Docker image as Curl command
We could include something like CMD curl https://code-maven.com in the Dockerfile, but then it would default to download the given page.
We could use CMD curl and hope to pass the URL to the docker run command, but the parameters given on the command-line will override everything we have in CMD.
However there is another tool called ENTRYPOINT. It is very similar to CMD, but in certain situations it allows the *addition* of parameters instead of the overwriting of parameters.
FROM ubuntu:20.04 RUN apt-get update RUN apt-get install -y curl ENTRYPOINT ["curl"]
$ docker build -t mydocker .
- Run alone will execute curl without parameters:
$ docker run --rm mydocker curl: try 'curl --help' or 'curl --manual' for more information
- Supply the URL and that's it:
$ docker run --rm mydocker https://code-maven.com/