Docker Essential

Docker Essential

1. Introduction

A. Docker editions:

Features

Docker Community Edition (CE)

Docker Enterprise Edition (EE)

Container engine with orchestration, networking and Security

yes

yes

Certified Infrastructure, plugins

-

yes

Image management - Docker Trusted Registry (DTR)

-

yes

Container application management - Docker Universal Control Plane (UCP)

-

yes

Secure image scanning

-

yes

Minimum Requirement


64 bit processor
4 GB RAM

8GB RAM for manager nodes
4GB of RAM for worker nodes
3 GB free disk space

Recommended production requirements

  • 16GB of RAM for manager nodes or nodes running DTR

  • 4 vCPUs for manager nodes or nodes running DTR

  • 25-100GB of free disk space

Docker Enterprise Edition (EE) is an integrated, supported platform for:

  • CentOS

  • Microsoft Windows Server 2016

  • Oracle Linux

B. Docker Architecture

Docker Engine is an open-source containerization technology for building and containerizing your applications. It is the heart of docker.Docker Engine acts as a client-server application with 3 things:

  1. dockerd: Docker daemon, it's the server.

  2. Docker client: CLI client, where you can interact with docker. Docker commands are used to talk with the docker server like to pull images, build images, and execute containers. CLI uses APIs to interact with docker daemon.

    APIs: APIs that specify interfaces that programs can use to talk to and instruct the Docker daemon.

  3. Docker registries: A Docker registry stores Docker images.

Docker Namespace: isolate the running container's resources (process ID, user IDs, network settings, storage, etc) from other containers running on the host os. Isolation is achieved using a namespace.

Types of namespaces in use by docker:

  • Process

  • Mount

  • Inner process communication (IPC)

  • Network

  • User

Cgroups in docker: Control groups (cgroups) are used to control container resources mainly CPU and Memory. It prevents a service attack or prevents noisy neighbor syndrome in a multi-tenant environment.

noisy neighbor syndrome
when there are multiple users on a single host all sharing the same underline resources, if one particular app is maximizing that server resources and you do not want to slow down all the other apps running on the same host

2. Installing Docker

  1. Remove docker

     sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce
    
  2. Update packages

     sudo apt-get update
    
  3. Allow Apt to use the repository over HTTPS (Installing Prerequisite Packages)

     sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
    
The above command will do:
Allows apt to transfer files and data over https, check security certificates, installs curl, a data-transfer utility, and adds scripts for software management.
  1. Add the Docker official GPG Key to Apt

     curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    
  2. Add the Docker Repository to Apt

     sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
    
  3. Specify installation Source

     apt-cache policy docker-ce
    
  4. Install Docker

     sudo apt install docker-ce -y
    
  5. Check Docker status

     sudo systemctl status docker
    
     docker --version
    
     docker run hello-world
    
  6. Add the user to the docker group

     sudo groupadd docker
    
     sudo usermod -aG docker $USER
    

    Log out and log in again.

3. Configuring Docker

Docker configuration files are stored over /var/lib/docker

/var/lib/docker/swarm --> swarm configuration

How to upgrade docker:

  1. go to the swarm configuration path. ie cd /var/lib/docker/swarm

  2. update the apt packages. ie sudo apt-get update

  3. uninstall docker

  4. install docker again (latest version of docker will get installed)

4. Troubleshooting Docker

Issue 1: Connection Refused by Port 22 Debian/Ubuntu

Reson could be like SSH service is inactive, the port is blocked by UFW firewall, the server is using a different port, or because of some IP conflict