Rushal Verma

@rusrushal13

Hello Docker

Docker is a new craze which is quite popular nowadays. I don’t know much before about it but at my internship, I attended a workshop from Dieter Reuter(Docker Captain)and Niclas Mietz from bee42 solutions gmbh.

It was quite fun two days workshop with them and I got to know a lot about it. So let’s get started with Docker.

Before getting started with it, you should install Docker on your machine. Take help from here how to install Docker.

Okay now, your machine has Docker, so now you may be thinking what Docker really is?

Docker is an open platform for building, shipping, and running applications. With Docker, you can manage your infrastructure in the same ways you manage your applications. It’s easy, simple and quite powerful too.

Okay as everyone knows we always start with Hello-world
 docker container run hello-world
In the output, you can see that we are doing many things(what Docker doing). But before that, I want to illustrate something regarding Docker Engine.

Docker Engine

Docker is same like your car, it has an engine which manages everything. It also consists a server known as Docker Daemon(thedockerdcommand) which manages everything for the client(Docker CLI). In between, the API handles the request from the client to the server. The server responds accordingly to the client by managing the images, containers, networks, and volumes.

  • Docker Daemon: The Docker daemon listens to API requests and manages Docker objects(images, containers, networks, and volumes). A daemon can also communicate with other daemons to manage Docker services(swarm mode).
  • Docker Client: The Docker client is the way that many Docker users interact with Docker. When you use commands such asdocker run the client sends these commands todockerd which carries them out. The docker command uses the Docker API. The Docker client can communicate with more than one daemon.
  • Docker Registries: A Docker registry stores Docker images. Docker Hub and Docker Cloud are public registries that anyone can use, and Docker is configured to look for images on Docker Hub by default. When you use the docker pullordocker run commands, the required images are pulled from your configured registry. When you use the docker pushcommand, your image is pushed to your configured registry. You can upgrade the application by pulling the new version of the image and redeploying the containers.
  • Images: An image is a snapshot of a Docker container. Often, an image is based on another image, with some additional customization. For example, you may build an image which is based on the ubuntu image but installs the Nginx web server and your application, as well as the configuration details needed to make your application run. Images are lightweight, small, and fast, when compared to other virtualization technologies.
  • Containers: A container is a runnable instance of an image. You can create, run, stop, move, or delete a container using the 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. By default, a container is relatively well isolated from other containers and its host machine. You can control how isolated a container’s network, storage, or other underlying subsystems are from other containers or from the host machine. A container is defined by its image as well as any configuration options you provide to it when you create or run it. When a container stops, any changes to its state that are not stored in persistent storage disappears.
  • Services: It allows you to scale containers across multiple Docker daemons, which all work together as a swarm with multiple managers and workers. Each member of a swarm is a Docker daemon, and the daemons all communicate using the Docker API. A service allows you to define the desired state, such as the number of replicas of the service that must be available at any given time. By default, the service is load-balanced across all worker nodes. To the consumer, the Docker service appears to be a single application.

After some theory let’s see the output now,

Hello from Docker!
  1. The docker client contacted to 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.

That’s it, pretty simple and easy. Enjoy the easiness of it.

More by Rushal Verma

Topics of interest

More Related Stories