[RedHat] Docker Install

RHEL8 환경에서 Docker를 설치하고 컨테이너를 실행하는 방법을 단계별로 정리합니다.


RHEL8에서 Docker 설치 개요

RHEL8부터는 Red Hat에서 Docker 지원을 공식적으로 중단했습니다. 이는 Red Hat이 더 이상 Docker 관련 RPM 패키지를 직접 제공하지 않는다는 의미입니다. 하지만 Docker 자체는 오픈소스로 배포되므로, 여전히 설치와 사용이 가능합니다.

단, Red Hat의 기술 지원 범위에서 벗어나므로 운영 환경에서는 안정성과 지원 측면을 고려해야 합니다. 레드햇 지원이 필요한 경우, Docker와 유사한 명령 체계를 가진 공식 지원 도구인 Podman을 사용하는 것을 권장합니다.

 

환경

- RHEL 8

 

Docker Install

 

1. Docker 레포지토리 설정

RHEL8에는 Docker 공식 패키지가 포함되어 있지 않기 때문에, CentOS용 Docker 레포지토리를 이용해 설치를 진행합니다. 아래 경로를 기반으로 docker.repo 파일을 생성합니다. 레포 설정이 궁금하다면 LocalRepo을 참조하면 됩니다.

아래는 Docker에서 제공하는 CentOs 용 레포 주소입니다.다. https://download.docker.com/linux/centos/


  • 레포 파일 생성
[root@localhost ~]# cat /etc/yum.repos.d/docker.repo
[docker]
name=docker
baseurl=https://download.docker.com/linux/centos/8/x86_64/stable/
gpgcheck=0
enabled=1
  • 레포지토리 설정 후 yum repolist -v 명령으로 설정한 레포에서 패키지 파일을 정상적으로 검출하는지 테스트할 수 있습니다.
[root@localhost ~]# yum repolist -v
Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_comple    tion_cache, groups-manager, needs-restarting, playground, product-id, repoclosure, repodiff, repograph, repoma    nage, reposync, subscription-manager, uploadprofile
Updating Subscription Management repositories.
Unable to read consumer identity

...

Repo-id            : docker
Repo-name          : docker
Repo-revision      : 1705314521
Repo-updated       : Mon 15 Jan 2024 07:28:41 PM KST
Repo-pkgs          : 191
Repo-available-pkgs: 191
Repo-size          : 3.5 G
Repo-baseurl       : <https://download.docker.com/linux/centos/8/x86_64/stable/>
Repo-expire        : 172,800 second(s) (last: Wed 17 Jan 2024 09:44:17 AM KST)
Repo-filename      : /etc/yum.repos.d/docker.repo
Total packages: 7,936

2. Docker 패키지 설치

Docker Engine, Containerd, Docker-compose의 최신 버전을 설치합니다. 

  • Docker Package Install

Docker Engine, CLI, Compose 등 필수 구성 요소를 포함한 패키지를 설치합니다. 설치 전 RHEL8 이미지의 Local Repo가 구성되어 있어야 의존성 문제가 발생하지 않습니다.

[root@localhost ~]# dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register    .

Last metadata expiration check: 0:00:44 ago on Wed 17 Jan 2024 09:44:18 AM KST.
Dependencies resolved.
==============================================================================================================
 Package                         Arch      Version                                         Repository    Size
==============================================================================================================
Installing:
 containerd.io                   x86_64    1.6.27-3.1.el8                                  docker        35 M
 docker-buildx-plugin            x86_64    0.11.2-1.el8                                    docker        13 M
 docker-ce                       x86_64    3:24.0.7-1.el8                                  docker        24 M
 docker-ce-cli                   x86_64    1:24.0.7-1.el8                                  docker       7.2 M
 docker-compose-plugin           x86_64    2.21.0-1.el8                                    docker        13 M
Installing dependencies:
 checkpolicy                     x86_64    2.9-1.el8                                       BaseOS       346 k
 container-selinux               noarch    2:2.158.0-1.module+el8.4.0+10607+f4da7515       AppStream     51 k
 fuse-common                     x86_64    3.2.1-12.el8                                    BaseOS        21 k
 fuse-overlayfs                  x86_64    1.4.0-2.module+el8.4.0+10607+f4da7515           AppStream     72 k
 fuse3                           x86_64    3.2.1-12.el8                                    BaseOS        50 k
 fuse3-libs                      x86_64    3.2.1-12.el8                                    BaseOS        94 k
 libcgroup                       x86_64    0.41-19.el8                                     BaseOS        70 k
 libslirp                        x86_64    4.3.1-1.module+el8.4.0+10607+f4da7515           AppStream     69 k
 policycoreutils-python-utils    noarch    2.9-14.el8                                      BaseOS       252 k
 python3-audit                   x86_64    3.0-0.17.20191104git1c2f876.el8                 BaseOS        86 k
 python3-libsemanage             x86_64    2.9-6.el8                                       BaseOS       127 k
 python3-policycoreutils         noarch    2.9-14.el8                                      BaseOS       2.2 M
 python3-setools                 x86_64    4.3.0-2.el8                                     BaseOS       626 k
 slirp4netns                     x86_64    1.1.8-1.module+el8.4.0+10607+f4da7515           AppStream     51 k
 tar                             x86_64    2:1.30-5.el8                                    BaseOS       838 k
Installing weak dependencies:
 docker-ce-rootless-extras       x86_64    24.0.7-1.el8                                    docker       4.9 M
Enabling module streams:
 container-tools                           rhel8

...

Complete!

 설치 과정에서는 다음과 같은 패키지들이 함께 설치됩니다:

  • docker-ce, docker-ce-cli, containerd.io: Docker의 핵심 구성요소

  • docker-compose-plugin, docker-buildx-plugin: 컨테이너 관리 및 멀티 아키텍처 빌드 지원

  • 의존성 패키지: container-selinux, fuse3, slirp4netns

모든 패키지가 정상적으로 설치되면 "Complete!" 메시지로 설치가 완료됩니다.

버전을 지정하시고 싶으신 분들은 Docker Documentation을 참조하실 수 있습니다.


3. Docker 데몬 실행 및 확인

  • Docker 버전 확인
[root@localhost ~]# docker --version
Docker version 24.0.7, build afdd53b
  • Docker가 설치되었으면 데몬을 기동하고 시스템 부팅 시 자동 시작되도록 설정합니다.
[root@localhost ~]# systemctl start docker

[root@localhost ~]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

[root@localhost ~]# 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 Wed 2024-01-17 09:47:30 KST; 8s ago
     Docs: <https://docs.docker.com>
 Main PID: 15716 (dockerd)
    Tasks: 8
   Memory: 26.3M
   CGroup: /system.slice/docker.service
           └─15716 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Jan 17 09:47:29 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
Jan 17 09:47:29 localhost.localdomain dockerd[15716]: time="2024-01-17T09:47:29.572536918+09:00" level=info msg=">
Jan 17 09:47:29 localhost.localdomain dockerd[15716]: time="2024-01-17T09:47:29.594184251+09:00" level=info msg=">
Jan 17 09:47:30 localhost.localdomain dockerd[15716]: time="2024-01-17T09:47:30.627630982+09:00" level=info msg=">
Jan 17 09:47:30 localhost.localdomain dockerd[15716]: time="2024-01-17T09:47:30.802197604+09:00" level=info msg=">
Jan 17 09:47:30 localhost.localdomain dockerd[15716]: time="2024-01-17T09:47:30.819245592+09:00" level=info msg=">
Jan 17 09:47:30 localhost.localdomain dockerd[15716]: time="2024-01-17T09:47:30.819379019+09:00" level=info msg=">
Jan 17 09:47:30 localhost.localdomain dockerd[15716]: time="2024-01-17T09:47:30.847685290+09:00" level=info msg=">
Jan 17 09:47:30 localhost.localdomain systemd[1]: Started Docker Application Container Engine.

 정상적으로 실행 중이라면, 데몬은 백그라운드에서 컨테이너를 관리할 준비가 완료된 상태입니다.


4. 컨테이너 기동 테스트


설치가 완료되었으면 테스트용 컨테이너를 실행해 Docker가 정상 동작하는지 확인할 수 있습니다. 여기서는 Apache 웹 서버(httpd) 이미지를 이용해 포트 8080으로 기동합니다.
[root@localhost ~]# docker run -d -p 8080:80 docker.io/library/httpd
Unable to find image 'httpd:latest' locally
latest: Pulling from library/httpd
2f44b7a888fa: Pull complete
5abb3599da34: Pull complete
4f4fb700ef54: Pull complete
fa608a886227: Pull complete
afe6bbf00437: Pull complete
fd0ef2a49677: Pull complete
Digest: sha256:7765977cf2063fec486b63ddea574faf8fbed285f2b17020fa7ef70a4926cdec
Status: Downloaded newer image for httpd:latest
056986a13b14a7b822d0b424a96fec9d1b82f60c462d89b5b514eb305d6cc9f1
  • 컨테이너 기동 확인
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND              CREATED         STATUS         PORTS                                   NAMES
056986a13b14   httpd     "httpd-foreground"   2 seconds ago   Up 2 seconds   0.0.0.0:8080->80/tcp, :::8080->80/tcp   nifty_pascal
  • 컨테이너 연결 테스트
[root@localhost ~]# curl localhost:8080
<html><body><h1>It works!</h1></body></html>

마치며

이번 글에서는 RHEL8에서 공식 지원되지 않는 Docker를 외부 레포지토리를 통해 설치하고, 컨테이너 기동까지 검증하는 방법을 단계별로 설명했습니다.

운영 환경에서는 Red Hat의 기술 지원을 받을 수 없는 Docker 대신, Podman을 사용하는 것이 보다 안전하고 권장되는 방법입니다. 다만 개발 및 테스트 용도에서는 Docker도 여전히 유효한 선택이 될 수 있습니다.


참조

https://access.redhat.com/discussions/6249651

https://access.redhat.com/solutions/3696691

https://docs.docker.com/engine/install/centos/

댓글

이 블로그의 인기 게시물

[Linux] RHEL Local YUM Repository 구성

[Linux Command] sudo command 설명

[Ansible Modules] Fetch module 설명 및 활용