Container - Docker

Docker Engine, Docker Registry

RELATED: DEVELOP > Container > Docker |

// Installl using deb apckage
sudo dpkg -i ./containerd.io_1.6.22-1_amd64.deb \
sudo dpkg -i ./docker-ce-cli_24.0.5-1~debian.12~bookworm_amd64.deb
sudo dpkg -i ./docker-ce_24.0.5-1~debian.12~bookworm_amd64.deb
sudo dpkg -i ./docker-buildx-plugin_0.11.2-1~debian.12~bookworm_amd64.deb
sudo dpkg -i ./docker-compose-plugin_2.20.2-1~debian.12~bookworm_amd64.deb

There are several types of installation including: Docker Engine, Docker Desktop, and Docker Compose.

Docker Engine is an open source containerization technology for building and containerizing your applications. Docker Engine acts as a client-server application with: - A server with a long-running daemon process dockerd - APIs which specify interfaces that programs can use to talk to and instruct the Docker daemon - A command line interface (CLI) client docker.

Docker Desktop is an application for Mac or Windows environment that enables you to build and share containerized applications and microservices. It provides a simple interface that enables you to manage your containers, applications, and images directly from your machine without having to use the CLI to perform core actions. It includes: - Docker Engine - Docker CLI client - Docker Compose - Docker Content Trust - Kubernetes Credential Helper

Docker Compose is Compose is a tool for defining and running multi-container Docker applications.

Setup - Docker Engine (debian)

Source: Install Docker Engine on Debian

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:        20.04
Codename:       focal
$
  • [Optional] Uninstall old versions of Docker (if installed) including: docker, docker.io, or docker-engine; Note: the contents of /var/lib/docker/, including images, containers, volumes, and networks, are preserved.

$ sudo apt-get remove docker docker-engine docker.io containerd runc
  • [Optional] Complete uninstalled existing Docker including: images, containers, volumes, or customized configuration files:

$ sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-compose-plugin
$ sudo rm -rf /var/lib/docker
$ sudo rm -rf /var/lib/containerd
  • Setup the repository to pull the binary from - there are different methods to install docker: install using the repository (recommended), install from a package, and install using the convenience script (for development environments quickly).

$ sudo apt-get update

// install packages to allow apt to use a repository over HTTPS
$ sudo apt-get install ca-certificates curl gnupg lsb-release

// add Docker’s official GPG key
$ sudo mkdir -p /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

// set up the repository
$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  • Install docker engine

$ sudo apt-get update

// install the latest version of Docker Engine, containerd, and Docker Compose
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
  • Verify installation

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
[...]
For more examples and ideas, visit:
 https://docs.docker.com/get-started/

$ sudo docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello-world   latest    feb5d9fea6a5   10 months ago   13.3kB

$ sudo docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
  • Post install for Windows WSL2 - Ubuntu; also need to be done after windows reboot otherwise "WSL2 Error...", as shown below.

$ sudo service docker start
 * Starting Docker: docker                             [ OK ]

$ sudo docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
  • Post install - during installation the docker group is created but no users are added to it. You need to use sudo to run Docker commands. The following setup allows non-privileged users to run Docker commands. NOTE: not needed for WSL setup.

// just in case, but docker group should have been created
$ cat /etc/group | grep docker
docker:x:999:
$ sudo groupadd docker
$ sudo usermod -aG docker $USER

// if the following does not work; try logout or restart
$ newgrp docker

// verify running not as root
$ docker run hello-world

How-to

WSL2 Error: docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

The above step, "Post install for Windows WSL2 - Ubuntu", is needed to start the docker service in the WSL2 Ubuntu environment, otherwise the error.

$ sudo service docker start

NOTE: this error happens after first install as well as after windows reboot.

Docker Registry

Setup account with one of the following providers, and make sure to check the pricing.

Docker artifacts on Debian

  • /etc/containerd/config.toml

Last updated