Black Friday 2025 – NPI EA (cat = Baeldung on Ops)
announcement - icon

Yes, we're now running our Black Friday Sale. All Access and Pro are 33% off until 2nd December, 2025:

>> EXPLORE ACCESS NOW

Baeldung Pro – Ops – NPI EA (cat = Baeldung on Ops)
announcement - icon

Learn through the super-clean Baeldung Pro experience:

>> Membership and Baeldung Pro.

No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.

Partner – Orkes – NPI EA (cat=Kubernetes)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

1. Overview

Docker provides a useful CLI to interact with a container. In this tutorial, we’ll see the run and start commands and highlight how they’re different while going through some practical examples.

2. Run a Container

Docker’s run command is a combination of its create and start commands. It creates a container over its specific image and then starts it. For example, let’s run a Postgres container:

docker run --name postgres_example -p 5432:5432 -v /volume:/var/lib/postgresql/data -e POSTGRES_PASSWORD=my_password -d postgres

Let’s have a look at our running containers with docker ps:

CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS         PORTS                                       NAMES
52b7c79bfaa8   postgres  "docker-entrypoint.s…"   22 seconds ago   Up 20 seconds  0.0.0.0:5432->5432/tcp, :::5432->5432/tcp   postgres_example

If we use docker logs, we can also check out more info about a started container, such as:

starting PostgreSQL 13.2
listening on IPv4 address "0.0.0.0", port 5432
listening on IPv6 address "::", port 5432
listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
database system is ready to accept connections

3. Start a Container

Docker’s start command starts a stopped container. A container can stop for different reasons – for example, when it has consumed too much memory and gets killed by the host OS.

To demonstrate this, let’s manually stop the container we created earlier:

docker stop 52b7c79bfaa8

In this case, our container’s running list will show an exited container:

CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS                    PORTS                                       NAMES
52b7c79bfaa8   postgres  "docker-entrypoint.s…"   2 minutes ago    Exited (0) 2 seconds ago  0.0.0.0:5432->5432/tcp, :::5432->5432/tcp   postgres_example

Let’s have a look also at the logs:

received fast shutdown request
aborting any active transactions
shutting down
database system is shut down

In case a container is down, we may want to start it again using docker start:

docker start 52b7c79bfaa8

If no errors occur while starting the container, we’ll be back to a running container status. Docker also provides the docker restart command, which combines stop and start into a single command.

4. Conclusion

In this tutorial, we briefly discussed the run and start commands in Docker.

We’ve seen an example of running a container using docker run. If a container stops, we can start it again with docker start.