based on:

Play with Docker Classroom

Containers and images

An image is a read-only template with instructions for creating a Docker container. A Docker registry stores Docker images.

Docker Hub (https://hub.docker.com/) is a public registry that anyone can use, and Docker is configured to look for images on Docker Hub by default; millions of images are available.

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

Run a single task “Hello World”

docker container run hello-world

https://i.imgur.com/113RKn6.png

https://hub.docker.com/_/hello-world

https://i.imgur.com/ntTx3DW.png

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: