Docker - Command (CMD)

Card Puncher Data Processing

About

cmd defines a command that should be run inside the container.

Definition

Inline

You can explicitly pass the cmd as argument to the docker cli.

docker run cmd # start a container and run a cmd
docker exec cmd # run a cmd against a running container

Example:

docker run -i -t ubuntu bash 
  • the image is ubuntu
  • the entrypoint is the default /bin/sh -c because there is no ENTRYPOINT in the ubuntu dockerfile
  • and the command is bash.

DockerFile

You can add a cmd 1) in a dockerfile

Management

Order of precedence

List

docker inspect --format "{{range .Config.Cmd}}{{.}}{{end}}" containerOrImageName





Discover More
Card Puncher Data Processing
Docker - Command (CMD)

cmd defines a command that should be run inside the container. You can explicitly pass the cmd as argument to the docker cli. Example: the image is ubuntu the entrypoint is the default /bin/sh...
Card Puncher Data Processing
How to run a docker image with example to create a container?

The run command creates: a container from an image running the docker host and calls the entrypoint script with the cmd values as arguments start To generate this message, Docker took...
Card Puncher Data Processing
What is the ENTRYPOINT docker instruction?

ENTRYPOINT is a docker instruction that defines the default docker entrypoint It has two different behavior that depends on the assignment format. ENTRYPOINT has the following forms: Command line...
Card Puncher Data Processing
What is the Entrypoint (Main) in Docker?

This page is the main entry in Docker. The entry point script is the command (or script) called when creating a container from an image with the docker run command When the entry point program exits,...



Share this page:
Follow us:
Task Runner