Sobes.tech
Middle

What is the difference between the commands docker start and docker run?

sobes.tech AI

Answer from AI

The docker run command is used to create and start a new container from a specified image. If the image is not available locally, Docker will automatically download it from the repository. This command combines creating and starting a container.

The docker start command is used to start an existing, but stopped, container. It does not create a new container or download an image.

Example:

# Create and start a new container
docker run -d --name my_container nginx

# Stop the container
docker stop my_container

# Start the existing container
docker start my_container

Thus, docker run is for creating and starting, while docker start is only for starting a previously created container.