What is the purpose of the 'docker run' command?

QuestionsQuestions8 SkillsProYour First Docker LabAug, 11 2025
0239

The docker run command is used to create and start a new container from a specified Docker image. It allows you to execute a command within the container and can include various options to customize the container's behavior, such as running it in detached mode, naming the container, or allocating a pseudo-TTY for interactive sessions.

Here’s a basic example of the command:

docker run <options> <image> <command>
  • <options>: Flags to modify the behavior (e.g., -d for detached mode, --name to assign a name).
  • <image>: The Docker image to use for creating the container.
  • <command>: The command to run inside the container.

For example, to run an interactive shell in an Alpine container, you would use:

docker run -it --name alpine_container alpine /bin/sh

0 Comments

no data
Be the first to share your comment!