Docker (in a nutshell)

Docker is an extension of LXC (Linux Container). It provides a lightweight virtualization solution to run processes in isolation from its environment.

Navigation

  1. What is a container ?
  2. Container VS Virtual Machine
  3. Docker Architecture
  4. Docker commands

1. What is a container ?

A container is a standard unit of software that packages up everything needed to run an application:

  • code
  • runtime
  • system tools
  • system libraries
  • settings

So the application runs quickly and reliably from one computing environment to another, regardless of the infrastructure.

Containers can run on the Docker Engine wich is available for Linux and Windows-based applications.

Containers isolate software from its environment and ensure that it works uniformly despite differences for instance between development and staging.


2. Container VS Virtual Machine

Containers and virtual machines have similar resource isolation and allocation benefits, but function differently because containers virtualize the operating system instead of hardware.

Docker vs Virtual Machine

3. Docker Architecture

The Docker Engine is a client-server application with these major components:

  • Client Docker
    The Docker client provides a command line interface (CLI) that allows you to build, run, and stop application commands to a Docker daemon. The main purpose of the Docker Client is to provide a means to direct the pull of images from a registry and to have it run on a Docker host.
  • Docker Host 
    A Docker host is a physical computer system or virtual machine running Linux on which Docker daemon runs.
  • Docker daemon
    The Docker daemon (dockerd) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. A daemon can also communicate with other daemons to manage Docker services.
  • Docker Registry
    A Docker registry stores Docker images. Docker Hub is a public registry that anyone can use, and Docker is configured to look for images on Docker Hub by default. You can even run your own private registry.
  • Images
    An image is a read-only template with instructions for creating 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 Apache web server and your application, as well as the configuration details needed to make your application run.
    You might create your own images or you might only use those created by others and published in a registry. To build your own image, you create a Dockerfile with a simple syntax for defining the steps needed to create the image and run it. Each instruction in a Dockerfile creates a layer in the image. When you change the Dockerfile and rebuild the image, only those layers which have changed are rebuilt. This is part of what makes images so lightweight, small, and fast, when compared to other virtualization technologies.
  • Containers
    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.
    STDOUT, STDERR and STDIN of a container are collected, recorded and available for analysis.


4. Docker commands

  • docker run – Runs a command in a new container.
  • docker start – Starts one or more stopped containers
  • docker stop – Stops one or more running containers
  • docker build – Builds an image form a Docker file
  • docker pull – Pulls an image or a repository from a registry
  • docker push – Pushes an image or a repository to a registry
  • docker export – Exports a container’s filesystem as a tar archive
  • docker exec – Runs a command in a run-time container
  • docker search – Searches the Docker Hub for images
  • docker attach – Attaches to a running container
  • docker commit – Creates a new image from a container’s changes

    Complete list Docker documentation