Skip to main content
Docker

Docker Run vs Start vs Create: Difference Explained

For a docker beginner, terms like docker start, docker run and docker create could be confusing. This article explains the difference with examples.

Abhishek Prakash

Warp Terminal

If you are new to Docker and learning it by following various tutorials, you might come across the terms like start docker container, run docker container or create docker container.

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

In fact, it is specially difficult to tell the difference between docker run and docker start.

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

Let me explain it to you.

Difference between Docker run, Docker start and Docker create

Here’s what these commands do:

Docker create command creates a fresh new container from a docker image. However, it doesn’t run it immediately.

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

Docker run command is a combination of create and start as 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 doesn’t find the mentioned image on your system.

Let’s see it with examples so that things are more clear to you.

Let’s see it with examples

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

Let’s say that you download the Ubuntu image from Docker Hub using docker pull ubuntu command.

You can see all the available docker images on your system. I have only ubuntu in this example (to avoid confusion):

abhishek@itsfoss:~$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              775349758637        5 weeks ago         64.2MB

Now, create a new docker container named container-1 with the docker create command:

abhishek@itsfoss:~$ docker create --name container-1 ubuntu
2d9a8c190e6c9b3cbbc032a87762bfbc92f1dc0dd30abbe9bdb3ed7e74a6480f

You can see that it has created a new container. If you try to see all the running containers, you won’t see container-1 because though it was created, it was never started.

abhishek@itsfoss:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

If you check all the containers, irrespective of whether they are running or not, you’ll see that container-1 has Created status:

abhishek@itsfoss:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
2d9a8c190e6c        ubuntu              "/bin/bash"         18 seconds ago      Created                                 container-1

Now let’s use the docker run command to create and run a container named container-2:

abhishek@itsfoss:~$ docker run -it -d --name container-2 ubuntu bash
13dc0f4226dc8d9d86e41d927c5616654d8263da2cc8c667aaa5b4dbd7f7e9b3

You can see that the container-2 is running as its status is Up:

abhishek@itsfoss:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS               NAMES
13dc0f4226dc        ubuntu              "bash"              About a minute ago   Up About a minute                       container-2

Let’s stop this running container:

abhishek@itsfoss:~$ docker stop container-2
container-2
abhishek@itsfoss:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
abhishek@itsfoss:~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
13dc0f4226dc        ubuntu              "bash"              2 minutes ago       Exited (0) 28 seconds ago                       container-2
2d9a8c190e6c        ubuntu              "/bin/bash"         3 minutes ago       Created                                         container-1

Now that we have a stopped container, you can start it again using the docker start command:

abhishek@itsfoss:~$ docker start container-2
container-2
abhishek@itsfoss:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
13dc0f4226dc        ubuntu              "bash"              2 minutes ago       Up 2 seconds                            container-2

But what happens to the container-1 which was created using docker create command? You can start this container with docker start command and then use docker exec to run something specific with it.

I hope this article gave you a better understanding of docker run, docker start and docker create command. I'll advise learning about the container lifecycle for further understanding this topic.

Docker Commands for Managing Container Lifecycle
Learn the container life cycle concept. Also learn the Docker commands to manage each stage of the lifecycle of the containers.

If you have questions or suggestion, please feel free to leave a comment below.

Abhishek Prakash