상세 컨텐츠

본문 제목

도커 설치 (centos7)

카테고리 없음

by 정혜리 2022. 12. 6. 16:08

본문

install docker - centos7


참조: https://docs.docker.com/engine/install/centos/#install-using-the-repository

 

 

1. 기존 도커 삭제 (재설치인 경우)

$ sudo yum remove docker \
                   docker-client \
                   docker-client-latest \
                   docker-common \
                   docker-latest \
                   docker-latest-logrotate \
                   docker-logrotate \
                   docker-engine



2. yum utils 설치

$ sudo yum install -y yum-utils



3. yum에 docker 저장소 설정

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



4-1. docker 엔진 설치 (최신버전설치)

$ sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
더보기

※ 설치 중 GPG 확인하라는 문구가 나오면 확인 후 일치하면 y하라는데 무슨말일까.. 일단 y하고 넘어감
========================== 터미널 로그 ==========================
Retrieving key from https://download.docker.com/linux/centos/gpg
Importing GPG key 0x621E9F35:
Userid     : "Docker Release (CE rpm) <docker@docker.com>"</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
======================================================================


4-2. docker 엔진 설치 (특정버전설치)

$ yum list docker-ce --showduplicates | sort -r

## 반환된 목록은 repository, centos의 버전에 따라 다름

$ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io docker-compose-plugin

 


 
5. docker 시작

$ sudo systemctl start docker




6. 제대로 시작되었는지 테스트 (hello-world 기동 테스트)

$ sudo docker run hello-world


아래와 같이 나오면 성공

더보기

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:faa03e786c97f07ef34423fccceeec2398ec8a5759259f94d99078f264e9d7af
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 사용자 추가

1. 그룹 생성
$ sudo groupadd docker
groupadd: group 'docker' already exists  // 이렇게 나오긴 했음

2. 그룹에 사용자 추가
$ sudo usermod -aG docker $USER

3. 재로그인 또는 아래 명령어 실행
$ newgrp docker

4. sudo 없이 도커명령어 사용할 수 있는지 확인
$ docker run hello-world


시스템 부팅 시 docker 자동 실행

1. systemd로 부팅 시 docker 서비스 실행 추가

$ sudo systemctl enable docker.service
### 정상 로그 : Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
$ sudo systemctl enable containerd.service
### 정상 로그 : Created symlink from /etc/systemd/system/multi-user.target.wants/containerd.service to /usr/lib/systemd/system/containerd.service.


2. 위 동작 정지시키기

$ sudo systemctl disable docker.service
$ sudo systemctl disable containerd.service