Rocky Linux 9.4에서 Docker-CE 설치 가이드

Docker-CE 설치 절차 ==================== 레포지토리 설정 변경 ------------------- 국내 사용자를 위한 알리클라우드 미러로 변경하여 설치 속도 개선
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
    -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g' \
    -i.bak \
    /etc/yum.repos.d/rocky*.repo
패키지 저장소 추가 ------------------ 다른 플랫폼에서 제공하는 레포지토리 추가
dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
설치 실행 --------- docker-ce 설치 시 자동으로 관련 라이브러리(컨테이너디, CLI 등)도 함께 설치됨
dnf install -y docker-ce
이 과정에서 자동으로 docker 그룹이 생성되며, 기본적으로 사용자는 해당 그룹에 포함되지 않음 비루트 사용자 권한 설정 --------------------- Docker 엔진은 TCP 포트 대신 유닉스 소켓을 사용함 기본적으로 유닉스 소켓은 루트 사용자만 접근 가능함 루트 권한 없이 실행하려면 docker 그룹을 생성하고 사용자를 추가해야 함
usermod -aG docker username
newgrp docker
서비스 설정 ------------ 시작 시 자동 실행 설정 및 서비스 시작
systemctl --now enable docker
설치 확인 ---------- hello-world 이미지 다운로드 후 실행하여 기본 메시지 확인
docker run hello-world
설치 로그 예시 ==============
[root@node200 ~]# uname -a
Linux node200 5.14.0-427.33.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 28 17:34:59 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
[root@node200 ~]# 
[root@node200 ~]# cat /etc/system-release
Rocky Linux release 9.4 (Blue Onyx)
[root@node200 ~]# 
[root@node200 ~]# dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
[root@node200 ~]# 
[root@node200 ~]# dnf install -y docker-ce
Rocky Linux 9 - BaseOS                                                                                       1.8 MB/s | 2.3 MB     00:01    
Rocky Linux 9 - AppStream                                                                                    4.4 MB/s | 8.0 MB     00:01    
Rocky Linux 9 - Extras                                                                                        20 kB/s |  15 kB     00:00    
Dependencies resolved.
=============================================================================================================================================
 Package                                    Architecture            Version                          Repository                         Size
=============================================================================================================================================
Installing:
 docker-ce                                  x86_64                  3:27.2.0-1.el9                   docker-ce-stable                   27 M
Installing dependencies:
 containerd.io                              x86_64                  1.7.21-3.1.el9                   docker-ce-stable                   43 M
 docker-ce-cli                              x86_64                  1:27.2.0-1.el9                   docker-ce-stable                  7.9 M
Installing weak dependencies:
 docker-buildx-plugin                       x86_64                  0.16.2-1.el9                     docker-ce-stable                   14 M
 docker-ce-rootless-extras                  x86_64                  27.2.0-1.el9                     docker-ce-stable                  4.0 M
 docker-compose-plugin                      x86_64                  2.29.2-1.el9                     docker-ce-stable                   13 M

Transaction Summary
=============================================================================================================================================
Install  6 Packages
......
......
......
Installed:
  containerd.io-1.7.21-3.1.el9.x86_64      docker-buildx-plugin-0.16.2-1.el9.x86_64           docker-ce-3:27.2.0-1.el9.x86_64               
  docker-ce-cli-1:27.2.0-1.el9.x86_64      docker-ce-rootless-extras-27.2.0-1.el9.x86_64      docker-compose-plugin-2.29.2-1.el9.x86_64     

Complete!
[root@node200 ~]#
[root@node200 ~]# usermod -aG docker username
[root@node200 ~]# newgrp docker
[root@node200 ~]#
[root@node200 ~]# systemctl --now enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[root@node200 ~]#
[root@node200 ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete 
Digest: sha256:53cc4d415d839c98be39331c948609b659ed725170ad2ca8eb36951288f81b75
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/

[root@node200 ~]#   
[root@node200 ~]# docker version
Client: Docker Engine - Community
 Version:           27.2.0
 API version:       1.47
 Go version:        go1.21.13
 Git commit:        3ab4256
 Built:             Tue Aug 27 14:17:06 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.2.0
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.21.13
  Git commit:       3ab5c7d
  Built:            Tue Aug 27 14:15:14 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.21
  GitCommit:        472731909fa34bd7bc9c087e4c27943f9835f111
 runc:
  Version:          1.1.13
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
[root@node200 ~]#
[root@node200 ~]# docker info
Client: Docker Engine - Community
 Version:    27.2.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.16.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.29.2
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 1
 Server Version: 27.2.0
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 472731909fa34bd7bc9c087e4c27943f9835f111
 runc version: v1.1.13-0-g58aa920
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.14.0-427.33.1.el9_4.x86_64
 Operating System: Rocky Linux 9.4 (Blue Onyx)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 7.506GiB
 Name: node200
 ID: 0ba20da2-13b0-4424-a09e-5fba22a975c3
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
[root@node200 ~]#
[root@node200 ~]# docker compose version
Docker Compose version v2.29.2
[root@node200 ~]#   
[root@node200 ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello-world   latest    d2c94e258dcb   16 months ago   13.3kB
[root@node200 ~]# 
[root@node200 ~]# docker ps -a
CONTAINER ID   IMAGE         COMMAND    CREATED              STATUS                          PORTS     NAMES
8c9ba6bc04b1   hello-world   "/hello"   About a minute ago   Exited (0) About a minute ago             unruffled_driscoll
[root@node200 ~]# 
daemon.json 설정 ================= - Docker 엔진 설정 파일 - 이미지 다운로드 가속기 설정 - 필요한 파라미터 조정
cat > /etc/docker/daemon.json << EOF
{
  "registry-mirrors": ["https://dockerpull.com"]
}
EOF
systemctl daemon-reload
참고 자료 ======== - https://www.rockylinux.cn/notes/zai-rocky-linux-9-1-shang-an-zhuang-docker-ce.html - https://docs.rockylinux.org/gemstones/containers/docker/ - https://docs.docker.com/engine/install/centos/

태그: docker Rocky Linux 9.4 containerd.io systemd Linux Container

5월 23일 00:29에 게시됨