sudo docker pull centos:latest
docker run -it --name centos /bin/bash
-i: 사용자가 입출력 할 수 있는 상태
-t: 가상 터미널 환경을 에뮬레이션 하겠다
-d: 컨테이너를 일반 프로세스가 아닌 데몬프로세스로 실행하여 프로세스가 끝나도 유지되도록 한다.
-e: 환경변수 설정, 옵션을 사용하면 Dockerfile의 ENV 설정도 덮어써지게 된다
-p: 호스트 컴퓨터에서 설정한 포트
-h: 컨테이너의 호스트 이름을 설정한다
--link: Docker 컨테이너끼리 연결할 때는 docker run 명령에서 --link 옵션을 사용
--rm: 컨테이너를 일회성으로 실행할 때 주로 쓰이는데, 컨테이너가 종료될 때 컨테이너와 관련된 리소스(파일 시스템, 볼륨)까지 깨끗이 제거해준다
-i 옵션과 -t 옵션은 같이 쓰이는 경우가 매우 많은데, 이 두 옵션은 컨테이너를 종료하지 않은체로, 터미널의 입력을 계속해서 컨테이너로 전달하기 위해서 사용한다
따라서, -it 옵션은 특히 컨테이너의 쉘(shell)이나 CLI 도구를 사용할 때 매우 유용하게 사용된다
즉,
t는 tty를 사용한다는 뜻, 즉 터미널과 비슷한 환경을 조성해주는 것
i는 입력에 대한 출력을 나타내는, 말 그대로 interactive한 흐름을 만들어 주는 옵션
(i 옵션을 주지 않으면 ls 했을때 list가 보이지 않는다)
CentOS안의 /bin/bash를 실행
bin/bash는 컨테이너가 시작할 때 마다 bash 쉘을 사용하겠다는 뜻 한다
(만약 bin/bash를 안쓰고 컨테이너를 만들면 ls, cd 등의 명령어가 먹히지 않을 텐데, bash 쉘 명령어를 사용하지 않도록 했기 때문이다)
Failed to set locale, defaulting to C.UTF-8
Error: Cannot find a valid baseurl for repo: appstream
System has not been booted with systemd as init system (PID 1). Can't operate.
EOS CentOS 8
CentOS 8 은 December 31, 2021 부로 EOS 되었다
지속적인 사용을 위해서는 CentOS 8 Stream 으로 배포판 변경을 해야지 지속적인 지원을 받을 수 있다
Error dnf
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
메시지가 나오면서 dnf 가 수행이 안되는 것을 확인 할 수 있다
yum 또한 사용 불가능
[root@chhan-c8 ~]# dnf repolist
CentOS Linux 8 - AppStream 87 B/s | 38 B 00:00
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
이는 CentOS 8 EOS 로 인해 CentOS 8 Mirror site 가 vault 로 전환되어 Mirror site 를 못 찾아 발생되는 문제
아래 명령어를 통해 기존에 Mirror site 를 Vault 로 전환하여 dnf 사용을 할 수 있다
[root@chhan-c8 ~]# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*
[root@chhan-c8 ~]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*
아래와 같이 정상적으로 repolist 를 받아오는 것을 확인 할 수 있다
[root@chhan-c8 ~]# dnf repolist
repo id repo name
appstream CentOS Linux 8 - AppStream
baseos CentOS Linux 8 - BaseOS
extras CentOS Linux 8 - Extras
[root@chhan-c8 ~]# cat /etc/yum.repos.d/CentOS-Linux-BaseOS.repo
...
[baseos]
name=CentOS Linux $releasever - BaseOS
#mirrorlist=http://#mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
baseurl=http://vault.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/ << vault site 로 변경
위와 같이 당장은 해결이 가능하지만 해당 Repo 는 더이상 Package 의 유지보수가 없으므로 보안에 취약하다
근본적인 해결을 위해서는 다른 배포판(ex. rocky linux 등) 이나 CentOS 8 Stream, RHEL 8 로 전환이 필요하다
dnf install centos-release-stream -y
dnf distro-sync -y
reboot
[root@762c91818dc9 ~]# dnf update
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:37:15 ago on Sat Sep 10 13:49:23 2022.
Error:
Problem 1: package centos-linux-repos-8-3.el8.noarch requires centos-gpg-keys = 1:8-3.el8, but none of the providers can be installed
- cannot install both centos-gpg-keys-1:8-6.el8.noarch and centos-gpg-keys-1:8-3.el8.noarch
- cannot install the best update candidate for package centos-linux-repos-8-2.el8.noarch
- cannot install the best update candidate for package centos-gpg-keys-1:8-2.el8.noarch
Problem 2: package centos-linux-repos-8-2.el8.noarch conflicts with centos-repos(8) provided by centos-stream-repos-8-2.el8.noarch
- package centos-stream-repos-8-2.el8.noarch conflicts with centos-repos(8) provided by centos-linux-repos-8-2.el8.noarch
- package centos-stream-release-8.6-1.el8.noarch requires centos-stream-repos, but none of the providers can be installed
- problem with installed package centos-linux-repos-8-2.el8.noarch
- package centos-stream-repos-8-3.el8.noarch requires centos-gpg-keys = 1:8-3.el8, but none of the providers can be installed
- package centos-linux-repos-8-3.el8.noarch requires centos-gpg-keys = 1:8-3.el8, but none of the providers can be installed
- package centos-linux-repos-8-3.el8.noarch conflicts with centos-repos(8) provided by centos-stream-repos-8-3.el8.noarch
- package centos-stream-repos-8-3.el8.noarch conflicts with centos-repos(8) provided by centos-linux-repos-8-3.el8.noarch
- package centos-linux-repos-8-2.el8.noarch requires centos-gpg-keys = 1:8-2.el8, but none of the providers can be installed
- package centos-stream-repos-8-2.el8.noarch requires centos-gpg-keys = 1:8-2.el8, but none of the providers can be installed
- cannot install both centos-gpg-keys-1:8-3.el8.noarch and centos-gpg-keys-1:8-2.el8.noarch
- package centos-stream-repos-8-4.el8.noarch requires centos-gpg-keys = 1:8-4.el8, but none of the providers can be installed
- cannot install both centos-gpg-keys-1:8-4.el8.noarch and centos-gpg-keys-1:8-2.el8.noarch
- cannot install both centos-gpg-keys-1:8-4.el8.noarch and centos-gpg-keys-1:8-3.el8.noarch
- package centos-stream-repos-8-6.el8.noarch requires centos-gpg-keys = 1:8-6.el8, but none of the providers can be installed
- cannot install both centos-gpg-keys-1:8-6.el8.noarch and centos-gpg-keys-1:8-2.el8.noarch
- cannot install both centos-gpg-keys-1:8-6.el8.noarch and centos-gpg-keys-1:8-3.el8.noarch
- cannot install the best update candidate for package centos-linux-release-8.4-1.2105.el8.noarch
- cannot install both centos-gpg-keys-1:8-2.el8.noarch and centos-gpg-keys-1:8-3.el8.noarch
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
[root@762c91818dc9 ~]# dnf update centos-gpg-keys --allowerasing
--allowerasing 옵션으로 강제로 업데이트
입력
dnf update centos-gpg-keys --allowerasing