Установка Docker на AlmaLinux 8

установить yum-utils:

dnf install yum-utils

добавить репозиторий Docker:

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

устанавливаем пакеты из репозитория Docker:

dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin

пример  успешной установки:

Docker CE Stable - x86_64                                                                                                         82 kB/s |  57 kB     00:00    
Dependencies resolved.
=================================================================================================================================================================
 Package                                     Architecture          Version                                                 Repository                       Size
=================================================================================================================================================================
Installing:
 containerd.io                               x86_64                1.6.28-3.1.el8                                          docker-ce-stable                 35 M
 docker-ce                                   x86_64                3:25.0.3-1.el8                                          docker-ce-stable                 26 M
 docker-ce-cli                               x86_64                1:25.0.3-1.el8                                          docker-ce-stable                7.3 M
 docker-compose-plugin                       x86_64                2.24.5-1.el8                                            docker-ce-stable                 13 M
Installing dependencies:
 checkpolicy                                 x86_64                2.9-1.el8                                               baseos                          347 k
 container-selinux                           noarch                2:2.221.0-1.module_el8.9.0+3643+9234dc3b                appstream                        68 k
 fuse-common                                 x86_64                3.3.0-17.el8                                            baseos                           21 k
 fuse-overlayfs                              x86_64                1.12-1.module_el8.9.0+3643+9234dc3b                     appstream                        69 k
 fuse3                                       x86_64                3.3.0-17.el8                                            baseos                           53 k
 fuse3-libs                                  x86_64                3.3.0-17.el8                                            baseos                           94 k
 libcgroup                                   x86_64                0.41-19.el8                                             baseos                           69 k
 libslirp                                    x86_64                4.4.0-1.module_el8.8.0+3615+3543c705                    appstream                        69 k
 policycoreutils-python-utils                noarch                2.9-24.el8                                              baseos                          253 k
 python3-audit                               x86_64                3.0.7-5.el8                                             baseos                           86 k
 python3-libsemanage                         x86_64                2.9-9.el8_6                                             baseos                          127 k
 python3-policycoreutils                     noarch                2.9-24.el8                                              baseos                          2.2 M
 python3-setools                             x86_64                4.3.0-5.el8                                             baseos                          626 k
 slirp4netns                                 x86_64                1.2.1-1.module_el8.9.0+3643+9234dc3b                    appstream                        55 k
 tar                                         x86_64                2:1.30-9.el8                                            baseos                          838 k
Installing weak dependencies:
 docker-buildx-plugin                        x86_64                0.12.1-1.el8                                            docker-ce-stable                 13 M
 docker-ce-rootless-extras                   x86_64                25.0.3-1.el8                                            docker-ce-stable                5.0 M
Enabling module streams:
 container-tools                                                   rhel8                                                                                        

Transaction Summary
=================================================================================================================================================================
Install  21 Packages

Total download size: 104 M
Installed size: 391 M
Is this ok [y/N]: y
Downloading Packages:
(1/21): fuse-common-3.3.0-17.el8.x86_64.rpm                                                                                      186 kB/s |  21 kB     00:00    
(2/21): fuse3-3.3.0-17.el8.x86_64.rpm                                                                                            456 kB/s |  53 kB     00:00    
(3/21): fuse3-libs-3.3.0-17.el8.x86_64.rpm                                                                                       2.7 MB/s |  94 kB     00:00    
(4/21): libcgroup-0.41-19.el8.x86_64.rpm                                                                                         2.0 MB/s |  69 kB     00:00    
(5/21): checkpolicy-2.9-1.el8.x86_64.rpm                                                                                         2.1 MB/s | 347 kB     00:00    
(6/21): python3-libsemanage-2.9-9.el8_6.x86_64.rpm                                                                               3.7 MB/s | 127 kB     00:00    
(7/21): python3-audit-3.0.7-5.el8.x86_64.rpm                                                                                     1.8 MB/s |  86 kB     00:00    
(8/21): policycoreutils-python-utils-2.9-24.el8.noarch.rpm                                                                       4.5 MB/s | 253 kB     00:00    
(9/21): tar-1.30-9.el8.x86_64.rpm                                                                                                3.4 MB/s | 838 kB     00:00    
(10/21): python3-setools-4.3.0-5.el8.x86_64.rpm                                                                                  2.3 MB/s | 626 kB     00:00    
(11/21): container-selinux-2.221.0-1.module_el8.9.0+3643+9234dc3b.noarch.rpm                                                     2.5 MB/s |  68 kB     00:00    
(12/21): python3-policycoreutils-2.9-24.el8.noarch.rpm                                                                           7.4 MB/s | 2.2 MB     00:00    
(13/21): libslirp-4.4.0-1.module_el8.8.0+3615+3543c705.x86_64.rpm                                                                1.9 MB/s |  69 kB     00:00    
(14/21): slirp4netns-1.2.1-1.module_el8.9.0+3643+9234dc3b.x86_64.rpm                                                             2.4 MB/s |  55 kB     00:00    
(15/21): fuse-overlayfs-1.12-1.module_el8.9.0+3643+9234dc3b.x86_64.rpm                                                           921 kB/s |  69 kB     00:00    
(16/21): docker-buildx-plugin-0.12.1-1.el8.x86_64.rpm                                                                            6.5 MB/s |  13 MB     00:01    
(17/21): docker-ce-cli-25.0.3-1.el8.x86_64.rpm                                                                                    14 MB/s | 7.3 MB     00:00    
(18/21): docker-ce-25.0.3-1.el8.x86_64.rpm                                                                                       9.3 MB/s |  26 MB     00:02    
(19/21): docker-ce-rootless-extras-25.0.3-1.el8.x86_64.rpm                                                                        11 MB/s | 5.0 MB     00:00    
(20/21): containerd.io-1.6.28-3.1.el8.x86_64.rpm                                                                                  11 MB/s |  35 MB     00:03    
(21/21): docker-compose-plugin-2.24.5-1.el8.x86_64.rpm                                                                            14 MB/s |  13 MB     00:00    
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                             18 MB/s | 104 MB     00:05     
Docker CE Stable - x86_64                                                                                                        4.7 kB/s | 1.6 kB     00:00    
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 From       : https://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                         1/1 
  Installing       : docker-compose-plugin-2.24.5-1.el8.x86_64                                                                                              1/21 
  Running scriptlet: docker-compose-plugin-2.24.5-1.el8.x86_64                                                                                              1/21 
  Installing       : fuse3-libs-3.3.0-17.el8.x86_64                                                                                                         2/21 
  Running scriptlet: fuse3-libs-3.3.0-17.el8.x86_64                                                                                                         2/21 
  Installing       : docker-buildx-plugin-0.12.1-1.el8.x86_64                                                                                               3/21 
  Running scriptlet: docker-buildx-plugin-0.12.1-1.el8.x86_64                                                                                               3/21 
  Installing       : docker-ce-cli-1:25.0.3-1.el8.x86_64                                                                                                    4/21 
  Running scriptlet: docker-ce-cli-1:25.0.3-1.el8.x86_64                                                                                                    4/21 
  Installing       : libslirp-4.4.0-1.module_el8.8.0+3615+3543c705.x86_64                                                                                   5/21 
  Installing       : slirp4netns-1.2.1-1.module_el8.9.0+3643+9234dc3b.x86_64                                                                                6/21 
  Installing       : tar-2:1.30-9.el8.x86_64                                                                                                                7/21 
  Running scriptlet: tar-2:1.30-9.el8.x86_64                                                                                                                7/21 
  Installing       : python3-setools-4.3.0-5.el8.x86_64                                                                                                     8/21 
  Installing       : python3-libsemanage-2.9-9.el8_6.x86_64                                                                                                 9/21 
  Installing       : python3-audit-3.0.7-5.el8.x86_64                                                                                                      10/21 
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                                                          11/21 
  Installing       : libcgroup-0.41-19.el8.x86_64                                                                                                          11/21 
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                                                          11/21 
  Installing       : fuse-common-3.3.0-17.el8.x86_64                                                                                                       12/21 
  Installing       : fuse3-3.3.0-17.el8.x86_64                                                                                                             13/21 
  Installing       : fuse-overlayfs-1.12-1.module_el8.9.0+3643+9234dc3b.x86_64                                                                             14/21 
  Running scriptlet: fuse-overlayfs-1.12-1.module_el8.9.0+3643+9234dc3b.x86_64                                                                             14/21 
  Installing       : checkpolicy-2.9-1.el8.x86_64                                                                                                          15/21 
  Installing       : python3-policycoreutils-2.9-24.el8.noarch                                                                                             16/21 
  Installing       : policycoreutils-python-utils-2.9-24.el8.noarch                                                                                        17/21 
  Running scriptlet: container-selinux-2:2.221.0-1.module_el8.9.0+3643+9234dc3b.noarch                                                                     18/21 
  Installing       : container-selinux-2:2.221.0-1.module_el8.9.0+3643+9234dc3b.noarch                                                                     18/21 
  Running scriptlet: container-selinux-2:2.221.0-1.module_el8.9.0+3643+9234dc3b.noarch                                                                     18/21 
  Installing       : containerd.io-1.6.28-3.1.el8.x86_64                                                                                                   19/21 
  Running scriptlet: containerd.io-1.6.28-3.1.el8.x86_64                                                                                                   19/21 
  Installing       : docker-ce-rootless-extras-25.0.3-1.el8.x86_64                                                                                         20/21 
  Running scriptlet: docker-ce-rootless-extras-25.0.3-1.el8.x86_64                                                                                         20/21 
  Installing       : docker-ce-3:25.0.3-1.el8.x86_64                                                                                                       21/21 
  Running scriptlet: docker-ce-3:25.0.3-1.el8.x86_64                                                                                                       21/21 
  Running scriptlet: container-selinux-2:2.221.0-1.module_el8.9.0+3643+9234dc3b.noarch                                                                     21/21 
  Running scriptlet: docker-ce-3:25.0.3-1.el8.x86_64                                                                                                       21/21 
  Verifying        : checkpolicy-2.9-1.el8.x86_64                                                                                                           1/21 
  Verifying        : fuse-common-3.3.0-17.el8.x86_64                                                                                                        2/21 
  Verifying        : fuse3-3.3.0-17.el8.x86_64                                                                                                              3/21 
  Verifying        : fuse3-libs-3.3.0-17.el8.x86_64                                                                                                         4/21 
  Verifying        : libcgroup-0.41-19.el8.x86_64                                                                                                           5/21 
  Verifying        : policycoreutils-python-utils-2.9-24.el8.noarch                                                                                         6/21 
  Verifying        : python3-audit-3.0.7-5.el8.x86_64                                                                                                       7/21 
  Verifying        : python3-libsemanage-2.9-9.el8_6.x86_64                                                                                                 8/21 
  Verifying        : python3-policycoreutils-2.9-24.el8.noarch                                                                                              9/21 
  Verifying        : python3-setools-4.3.0-5.el8.x86_64                                                                                                    10/21 
  Verifying        : tar-2:1.30-9.el8.x86_64                                                                                                               11/21 
  Verifying        : container-selinux-2:2.221.0-1.module_el8.9.0+3643+9234dc3b.noarch                                                                     12/21 
  Verifying        : fuse-overlayfs-1.12-1.module_el8.9.0+3643+9234dc3b.x86_64                                                                             13/21 
  Verifying        : libslirp-4.4.0-1.module_el8.8.0+3615+3543c705.x86_64                                                                                  14/21 
  Verifying        : slirp4netns-1.2.1-1.module_el8.9.0+3643+9234dc3b.x86_64                                                                               15/21 
  Verifying        : containerd.io-1.6.28-3.1.el8.x86_64                                                                                                   16/21 
  Verifying        : docker-buildx-plugin-0.12.1-1.el8.x86_64                                                                                              17/21 
  Verifying        : docker-ce-3:25.0.3-1.el8.x86_64                                                                                                       18/21 
  Verifying        : docker-ce-cli-1:25.0.3-1.el8.x86_64                                                                                                   19/21 
  Verifying        : docker-ce-rootless-extras-25.0.3-1.el8.x86_64                                                                                         20/21 
  Verifying        : docker-compose-plugin-2.24.5-1.el8.x86_64                                                                                             21/21 

Installed:
  checkpolicy-2.9-1.el8.x86_64                                          container-selinux-2:2.221.0-1.module_el8.9.0+3643+9234dc3b.noarch                       
  containerd.io-1.6.28-3.1.el8.x86_64                                   docker-buildx-plugin-0.12.1-1.el8.x86_64                                                
  docker-ce-3:25.0.3-1.el8.x86_64                                       docker-ce-cli-1:25.0.3-1.el8.x86_64                                                     
  docker-ce-rootless-extras-25.0.3-1.el8.x86_64                         docker-compose-plugin-2.24.5-1.el8.x86_64                                               
  fuse-common-3.3.0-17.el8.x86_64                                       fuse-overlayfs-1.12-1.module_el8.9.0+3643+9234dc3b.x86_64                               
  fuse3-3.3.0-17.el8.x86_64                                             fuse3-libs-3.3.0-17.el8.x86_64                                                          
  libcgroup-0.41-19.el8.x86_64                                          libslirp-4.4.0-1.module_el8.8.0+3615+3543c705.x86_64                                    
  policycoreutils-python-utils-2.9-24.el8.noarch                        python3-audit-3.0.7-5.el8.x86_64                                                        
  python3-libsemanage-2.9-9.el8_6.x86_64                                python3-policycoreutils-2.9-24.el8.noarch                                               
  python3-setools-4.3.0-5.el8.x86_64                                    slirp4netns-1.2.1-1.module_el8.9.0+3643+9234dc3b.x86_64                                 
  tar-2:1.30-9.el8.x86_64                                              

Complete!

Если нужно, чтобы Docker работал не от root, то необходимо добавить пользователя в созданную после установки группу docker:

usermod -aG docker <имя пользователя>

запустить и добавить в автозапуск:

systemctl start docker
systemctl enable docker

проверить работу демона:

systemctl status docker

пример успешного статуса:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2024-02-10 17:44:30 +06; 7s ago
     Docs: https://docs.docker.com
 Main PID: 56323 (dockerd)
    Tasks: 10
   Memory: 33.5M
   CGroup: /system.slice/docker.service
           └─56323 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Feb 10 17:44:29 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
Feb 10 17:44:29 localhost.localdomain dockerd[56323]: time="2024-02-10T17:44:29.202481830+06:00" level=info msg="Starting up"
Feb 10 17:44:29 localhost.localdomain dockerd[56323]: time="2024-02-10T17:44:29.263927569+06:00" level=info msg="Loading containers: start."
Feb 10 17:44:30 localhost.localdomain dockerd[56323]: time="2024-02-10T17:44:30.206501711+06:00" level=info msg="Firewalld: interface docker0 already part of do>
Feb 10 17:44:30 localhost.localdomain dockerd[56323]: time="2024-02-10T17:44:30.318301205+06:00" level=info msg="Loading containers: done."
Feb 10 17:44:30 localhost.localdomain dockerd[56323]: time="2024-02-10T17:44:30.335068819+06:00" level=info msg="Docker daemon" commit=f417435 containerd-snapsh>
Feb 10 17:44:30 localhost.localdomain dockerd[56323]: time="2024-02-10T17:44:30.335383827+06:00" level=info msg="Daemon has completed initialization"
Feb 10 17:44:30 localhost.localdomain dockerd[56323]: time="2024-02-10T17:44:30.375803954+06:00" level=info msg="API listen on /run/docker.sock"
Feb 10 17:44:30 localhost.localdomain systemd[1]: Started Docker Application Container Engine.

проверка версии docker:

docker --version

проверка работы docker:

docker run hello-world

пример успешной проверки:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete 
Digest: sha256:4bd78111b6914a99dbc560e6a20eab57ff6655aea4a80c50b0c5491968cbc2e6
Status: Downloaded newer image for hello-world:latest

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.
    (amd64)
 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 ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

 

установка docker-compose

копировать релиз из github:

DC_VERSION="$(curl -I https://github.com/docker/compose/releases/latest | awk -F '/' '/^location/ {print  substr($NF, 1, length($NF)-1)}')" && curl -L "https://github.com/docker/compose/releases/download/$DC_VERSION/docker-compose-linux-$(uname -m)" -o /usr/local/bin/docker-compose

права на выполнение:

chmod +x /usr/local/bin/docker-compose

проверить версию:

docker-compose --version

пример результата:

Docker Compose version v2.24.5

 

удаление docker

удаление основных пакетов:

dnf remove docker-ce docker-ce-cli containerd.io docker-compose-plugin

удаление остатков от docker и контейнеров:

rm -rf /var/lib/docker /var/lib/containerd

удаление docker-compose:

rm -rf /usr/local/bin/docker-compose