Starting a New Container
Learn how to start new container using Docker CLI.
Now that you have an overview, let’s see how to use Docker to create a new container.
Starting containers using the Docker CLI
The most common way of starting containers is using the Docker CLI. Run the following command to start a new container called ctr1
based on the nginx
image.
docker run -d --name ctr1 nginx
Starting a new container
Run a docker ps
command to see if the container is running.
$ docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES9cfb0c9aacb2 nginx "/docker-entrypoint.…" 9 seconds ago Up 9 seconds 80/tcp ctr1
Check whether a container is running
When you run commands like this, the Docker client converts them into API requests and sends them to the API exposed by the daemon. The daemon can expose the API on a local socket or over the network. On Linux, the local socket is /var/run/docker.sock
and on Windows it’s \pipe\docker_engine
.
The daemon receives the ...