based on: https://training.play-with-docker.com/
A container is a runnable instance of an image. You can create, start, stop, move, or delete a container using the Docker API or CLI. You can connect a container to one or more networks, attach storage to it, or even create a new image based on its current state.
There are three different ways to use containers. These include:
In the following, we will see examples of all three ways to use containers
The command run
creates a container from an image and executes the command that is indicated.
docker container run hello-world
Images can have multiple versions. For example you could pull a specific version of ubuntu
image as follows:
docker pull ubuntu:12.04
If you do not specify the version number of the image the Docker client will default to a version named latest
.
So, for example, the docker pull
command given below will pull an image named ubuntu:latest
:
docker pull ubuntu