Command is a process that is specified in the DockerFile, which should be executed when a Docker image is run.
The arguments will have to be hard-coded within the Dockerfile.
Docker File:
CMD ["sleep","10"] OR CMD sleep 10
Docker Run:
This will execute
docker run alpine sleep 10
This will allow the command arguments to be dynamic, rather than hard-coded in the DockerFile
Docker File:
ENTRYPOINT ["sleep"]
Docker Run:
This will execute
docker run alpine sleep 15
To set a default value to an EntryPoint command,
Docker File:
ENTRYPOINT ["sleep"]
CMD ["5"]
Docker Run:
This will execute
docker run alpine sleep 5
docker run alpine 20
This will execute
docker run alpine sleep 20
To override the entrypoint command runtime, pass an entrypoint argument while running a docker container -
Eg:
docker run --entrypoint sleep2 alpine 10
----- this executes sleep2 process instead of sleep which is in the dockerfile
No comments:
Post a Comment