[Linux] Rocky Linux 9에 Docker 설치
사용환경
- Hardware : VMware
- OS : Rocky Linux 9.5 (Blue Onyx)
A. 시작하기 전에..
Docker 테스트를 위해서 VMware에 가상서버를 생성하고 Rocky Linux를 설치했다. 개인적으로는 Ubuntu를 선호하는 편인데, 회사에서 사용할 서버라서 다른 사람들과 같이 사용하기 위해서 RHEL이나 RHEL과 호환되는 배포판을 선택해서 사용하는 편이다.
B. Docker 설치 전 작업
01. OS 최신화
$ sudo yum -y update
작업을 시작하기 전에 OS 업데이트를 전부 수행해준다. (작업 후에 업데이트를 할 경우에 가끔 문제가 생기기도해서...)
$ sudo reboot
마찬가지로 기존 작업과의 연관성을 끊기 위해서 새로 시작하는 느낌으로 OS 재부팅을 수행한다.
02. 시간대 점검
재부팅이 완료되면 시간대 정보를 확인한다. 가능하면 KST로...
$ sudo timedatectl
Local time: Fri 2025-04-11 12:07:28 KST
Universal time: Fri 2025-04-11 03:07:28 UTC
RTC time: Fri 2025-04-11 03:07:26
Time zone: Asia/Seoul (KST, +0900)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no
$
시간서버로 동기화가 안되있어서 해당 서비스를 켜준다.
$ sudo systemctl status chronyd
○ chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; disabled; preset: enabled)
Active: inactive (dead)
Docs: man:chronyd(8)
man:chrony.conf(5)
$ sudo systemctl enable --now chronyd
Created symlink /etc/systemd/system/multi-user.target.wants/chronyd.service → /usr/lib/systemd/system/chronyd.service.
$
03. Docker 저장소추가
추후에 업데이트를 원활하게 수횅할 수 있도록 저장소를 등록한다.(만약 버전을 유지하고 싶다면 수동으로 설치를 하는 것이 좋을 것 같다.)
$ sudo dnf -y install dnf-plugins-core
Last metadata expiration check: 0:27:37 ago on Fri 11 Apr 2025 11:58:30 AM KST.
Package dnf-plugins-core-4.3.0-16.el9.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
$ sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
Adding repo from: https://download.docker.com/linux/rhel/docker-ce.repo
$
C. Docker 설치
$ sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
저장소를 구성했으므로 위와 같은 명령어로 쉽게 설치가 가능하다!(이게 리눅스 쓰면서 윈도우보다 오히려 편했던 점....)
D. Docker 실행
$ sudo systemctl enable --now docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
docker 서비스를 올리고 서버 기동 시에 서비스가 같이 시작되도록 구성한다.
$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: disabled)
Active: active (running) since Fri 2025-04-11 12:29:11 KST; 5s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 7326 (dockerd)
Tasks: 13
Memory: 25.9M
CPU: 99ms
CGroup: /system.slice/docker.service
└─7326 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Apr 11 12:29:11 dockerts dockerd[7326]: time="2025-04-11T12:29:11.019278147+09:00" level=info msg="Creating a containerd client" address=/>
Apr 11 12:29:11 dockerts dockerd[7326]: time="2025-04-11T12:29:11.042439256+09:00" level=info msg="Loading containers: start."
Apr 11 12:29:11 dockerts dockerd[7326]: time="2025-04-11T12:29:11.062335428+09:00" level=info msg="Firewalld: created docker-forwarding po>
Apr 11 12:29:11 dockerts dockerd[7326]: time="2025-04-11T12:29:11.751792456+09:00" level=info msg="Loading containers: done."
Apr 11 12:29:11 dockerts dockerd[7326]: time="2025-04-11T12:29:11.761026323+09:00" level=info msg="Docker daemon" commit=6430e49 container>
Apr 11 12:29:11 dockerts dockerd[7326]: time="2025-04-11T12:29:11.761086266+09:00" level=info msg="Initializing buildkit"
Apr 11 12:29:11 dockerts dockerd[7326]: time="2025-04-11T12:29:11.784953957+09:00" level=info msg="Completed buildkit initialization"
Apr 11 12:29:11 dockerts dockerd[7326]: time="2025-04-11T12:29:11.790278445+09:00" level=info msg="Daemon has completed initialization"
Apr 11 12:29:11 dockerts dockerd[7326]: time="2025-04-11T12:29:11.790320803+09:00" level=info msg="API listen on /run/docker.sock"
Apr 11 12:29:11 dockerts systemd[1]: Started Docker Application Container Engine.
$
서비스가 잘 올라왔는지 확인해보고...
$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
e6590344b1a5: Pull complete
Digest: sha256:424f1f86cdf501deb591ace8d14d2f40272617b51b374915a87a2886b2025ece
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 공식 설치문서에 나와있는 것처럼 hello-world로 테스트해보면 완료!
E. 마치면서..
블로그에 글 쓰는게 뭐 이리 어려운지.. 쓰려고 노력해도 잘 되질 않는다.
가볍게 쓰는건 맘에 들지 않고, 그렇다고 거창하게 쓰려고 맘먹으면 계속 미루게 되고...
"뭐라도 계속 쓰는게 좋지 않을까?"라고 생각하다가 오늘도 즉흥적으로 그냥 간단한 작업을 하면서 글을 써본다.
알고는 있지만 누군가에게 내 글이 도움이 되길 바라진 않지만, 창피하고 싶진 않고... 결국 글을 쓰면서 내 지식이 늘어나는건데 왜 계속 미루고 글감만 만들어두고 덮는지...ㅋ
결국 게으름의 문제일지도
F. 참고문서
- Install Docker Engine on RHEL
, Docker Inc., Docker Docs - [초간단]록키 리눅스 9.4에 ntp, chrony 서버 구축하기(2024.05), 대보름, 긍정적이고 행동하는 삶 - 재테크, IT이야기, 2024/05/20