Starting a container
Once we have the images, we can use them to start containers. In this recipe, we will start a container with the ubuntu:latest
image and see what happens behind the scenes.
Getting ready
Ensure that the Docker daemon is running on the host and can be connected through the Docker client.
How to do it...
We can start a container using either of the following syntaxes:
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]docker container run [OPTIONS] IMAGE [COMMAND] [ARG...]
Note
The docker container run
command is recommended over docker run
because, in version 1.13, Docker logically grouped container operations under the docker container management
command, and so docker run
might be obsolete in the future.
Here is an example of using the docker container run
command:
$ docker container run -i -t --name mycontainer ubuntu /bin/bash
By default, Docker picks the image with the latest tag:
- The
-interactive
or-i
option starts the container in interactive mode by keeping theSTDIN
open - The...