Difference between Run, Start and Create Commands in Docker

If you are new to Docker and are just starting to learn it by following various tutorials, you may come across terms like starting a Docker container, starting a Docker container, or creating a Docker container.

These terms are enough to confuse a beginner docker, because all three Docker commands seem to be similar.

In fact, it is especially difficult to tell the difference between starting and starting Docker.

Isn’t starting a container the same as starting it? Not really.

Let us explain this to you.

Difference between Run, Start and Create in Docker

Let’s see what these commands do:

Docker create command creates a new container from the Docker image. However, it doesn’t start right away.

The start Docker command will start any stopped container. If you’ve used the docker create command to create a container, you can start it with this command.

The run Docker command is a combination of create and start because it creates a new container and starts it immediately. In fact, the docker run command can even pull an image from Docker Hub if it does not find the mentioned image on your system.

Let’s look at it with examples to make it clearer for you.

Let’s look at examples

Make sure you have Docker installed if you want to follow along with the examples.

Let’s say you are downloading an Ubuntu image from Docker Hub using the docker pull ubuntu command.

You can see all available Docker images on your system. We only have Ubuntu in this example (to avoid confusion):

$ docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

ubuntu latest 775349758637 5 weeks ago 64.2MB

Now create a new Docker container named container-2 using the docker create command:

$ docker create --name container-2 ubuntu

2d9a8c190e6c9b3cbbc032a87762bfbc92f1dc0dd30abbe9bdb3ed7e74a64890

As you can see, the team has created a new container. If you try to see all the running container-2, you won’t see the container because although it was created, it never started.

$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

If you check all containers, whether they are running or not, you see that container-2 has a Created status:

$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2d9a8c190e6d ubuntu "/ bin / bash" 10 seconds ago Created container-1

That’s all in this post. Hope your doubt is clear and you understand Docker commands differences very well.

Avatar

About Shachindra Yadav

I, Shachindra Yadav, a Cloud Certified, DevOps and technology enthusiastic person, more passionate to learn and write blogs in my free time.

View all posts by Shachindra Yadav →