Hello Docker

In Dockerland, there are Registries, images and there are containers. The three are closely intertwined, but distinct.

An image is worth a thousand words

Docker Architecture

What is this Docker registry?

The Registry is a stateless, highly scalable server side application that stores and lets you distribute Docker images. - https://docs.docker.com/registry/

What is a Docker image?

An image is an inert, immutable, file that's essentially a snapshot of a container. Images are created with the build command, and they'll produce a container when started with docker run.

A search for Ubuntu images under https://hub.docker.com/ yields these results

Docker search results

On the command line, one could do the same:

docker search ubuntu

NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
ubuntu                            Ubuntu is a Debian-based Linux operating s...   4846      [OK]
ubuntu-upstart                    Upstart is an event-based replacement for ...   66        [OK]
rastasheep/ubuntu-sshd            Dockerized SSH service, built on top of of...   42                   [OK]
ubuntu-debootstrap                debootstrap --variant=minbase --components...   28        [OK]

Hello Docker

Let's run the classical hello world for Docker:
docker run hello-world

If you can see the below, this means that it works. As you can see, behind the scene, Docker did a lot to make this work:

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

(We can also run the ubuntu version of hello world by simply doing:

docker run ubuntu /bin/echo hello world)

What is this Docker container?

To use a programming metaphor, if an image is a class, then a container is an instance of a class—a runtime object. Containers are hopefully why you're using Docker; they're lightweight and portable encapsulations of an environment in which to run applications.

Container and Virtualization side by side

virt-vs-container

Up next

To recap, Here we saw words like, docker hub/registry, images, containers...

  • a registry can be public or private, and usually publish images
  • images can be pulled, pushed to a registry. images are build from Dockerfile's
  • containers can be created from images, by running a given image

In the following posts we will install a private registry, build our first image and push it to our registry.