Search⌘ K

Starting a Container

Explore how to start a Docker container with the docker run command, including running containers in detached mode, naming containers, port mapping, and how Docker pulls images from repositories. Understand the process behind container creation and verify your container is running to interact with your app effectively.

We'll cover the following...

The docker run command is the simplest and most common way to start a new container. Run the following command to start a new container called webserver.

$ docker run -d --name webserver -p 5005:8080 nigelpoulton/ddd-book:web0.1
Unable to find image 'nigelpoulton/ddd-book:web0.1' locally
web0.1: Pulling from nigelpoulton/ddd-book
4f4fb700ef54: Already exists
cf2a607f33f7: Download complete
0a1f0c111e9a: Download complete
c1af4b5db242: Download complete
Digest: sha256:3f5b281b914b1e39df8a1fbc189270a5672ff9e98bfac03193b42d1c02c43ef0
Status: Downloaded newer image for nigelpoulton/ddd-book:web0.1
b5594b3b8b3fdce544d2ca048e4340d176bce9f5dc430812a20f1852c395e96b
Starting a docker container

Explanation

Let’s take a closer look at the command and the output:

  • The docker run instructs Docker to run a new container.

  • The -d flag tells Docker to run it in the background as a daemon process and detach from the local terminal. ...