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...
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.1Unable to find image 'nigelpoulton/ddd-book:web0.1' locallyweb0.1: Pulling from nigelpoulton/ddd-book4f4fb700ef54: Already existscf2a607f33f7: Download complete0a1f0c111e9a: Download completec1af4b5db242: Download completeDigest: sha256:3f5b281b914b1e39df8a1fbc189270a5672ff9e98bfac03193b42d1c02c43ef0Status: Downloaded newer image for nigelpoulton/ddd-book:web0.1b5594b3b8b3fdce544d2ca048e4340d176bce9f5dc430812a20f1852c395e96b
Starting a docker container
Explanation
Let’s take a closer look at the command and the output:
-
The
docker runinstructs Docker to run a new container. -
The
-dflag tells Docker to run it in the background as a daemon process and detach from the local terminal. ...