Docker

Docker 설치

ZzangHo 2022. 1. 26. 22:37
728x90

Linux에 Docker 설치를 해보자

[root@hostname ~]# sudo wget -qO- https://get.docker.com/ | sh
# Executing docker install script, commit: 7cae5f8b0decc17d6571f9f52eb840fbc13b2737
+ sh -c 'yum install -y -q yum-utils'
https://epel.mirror.constant.com/7/x86_64/repodata/4ff8fcc825c1fbd43cf4074655dde6703a1caa7e2525b92a7e9a3277b7596196-primary.sqlite.bz2: [Errno 14] curl#22 - "The requested URL returned error: 403"
Trying other mirror.
https://sjc.edge.kernel.org/fedora-buffet/epel/7/x86_64/repodata/4ff8fcc825c1fbd43cf4074655dde6703a1caa7e2525b92a7e9a3277b7596196-primary.sqlite.bz2: [Errno 14] curl#22 - "The requested URL returned error: 403"
Trying other mirror.
No Presto metadata available for base
Warning: RPMDB altered outside of yum.
+ sh -c 'yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo'
Loaded plugins: fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
+ '[' stable '!=' stable ']'
+ sh -c 'yum makecache'
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                          |  16 kB  00:00:00
 * base: mirror.kakao.com
 * epel: d2lzkl7pfhq30w.cloudfront.net
 * extras: mirror.kakao.com
 * updates: mirror.anigil.com
base                                                                                          | 3.6 kB  00:00:00
docker-ce-stable                                                                              | 3.5 kB  00:00:00
extras                                                                                        | 2.9 kB  00:00:00
updates                                                                                       | 2.9 kB  00:00:00
(1/13): docker-ce-stable/7/x86_64/filelists_db                                                |  25 kB  00:00:00
(2/13): docker-ce-stable/7/x86_64/primary_db                                                  |  60 kB  00:00:00
(3/13): docker-ce-stable/7/x86_64/other_db                                                    | 118 kB  00:00:00
(4/13): docker-ce-stable/7/x86_64/updateinfo                                                  |   55 B  00:00:00
(5/13): base/7/x86_64/other_db                                                                | 2.6 MB  00:00:01
(6/13): epel/x86_64/filelists_db                                                              |  12 MB  00:00:02
(7/13): epel/x86_64/prestodelta                                                               |  325 B  00:00:00
(8/13): extras/7/x86_64/other_db                                                              | 138 kB  00:00:00
(9/13): base/7/x86_64/filelists_db                                                            | 7.2 MB  00:00:02
(10/13): extras/7/x86_64/filelists_db                                                         | 230 kB  00:00:00
(11/13): epel/x86_64/other_db                                                                 | 3.4 MB  00:00:00
(12/13): updates/7/x86_64/other_db                                                            | 569 kB  00:00:00
(13/13): updates/7/x86_64/filelists_db                                                        | 4.3 MB  00:00:00
Metadata Cache Created
+ '[' -n '' ']'
+ sh -c 'yum install -y -q docker-ce'
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/containerd.io-1.4.4-3.1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for containerd.io-1.4.4-3.1.el7.x86_64.rpm is not installed
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 From       : https://download.docker.com/linux/centos/gpg
setsebool:  SELinux is disabled.
 
+ '[' -n 1 ']'
+ sh -c 'yum install -y -q docker-ce-rootless-extras'
Package docker-ce-rootless-extras-20.10.6-3.el7.x86_64 already installed and latest version
 
================================================================================
 
To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:
 
    dockerd-rootless-setuptool.sh install
 
Visit https://docs.docker.com/go/rootless/ to learn about rootless mode.
 
 
To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to https://docs.docker.com/go/daemon-access/
 
WARNING: Access to the remote API on a privileged Docker daemon is equivalent
         to root access on the host. Refer to the 'Docker daemon attack surface'
         documentation for details: https://docs.docker.com/go/attack-surface/
 
================================================================================
 
[root@hostname ~]#
[root@hostname ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.6
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        370c289
 Built:             Fri Apr  9 22:45:33 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? // 서비스가 시작이 되지 않으면 이렇게 docker.sock이 실행이 되지 않았다고 메세지가 나온다.

 

위의 예시대로 따라 하면 정상적으로 설치가 완료 될 것이다. 

 

서비스 시작 및 reboot 등록

[root@hostname ~]# sudo service docker start
Redirecting to /bin/systemctl start docker.service
[root@hostname ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.6
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        370c289
 Built:             Fri Apr  9 22:45:33 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
 
Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:43:57 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
[root@hostname ~]# sudo chkconfig docker on
알림: 'systemctl enable docker.service'에 요청을 전송하고 있습니다.
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@hostname ~]#

'Docker' 카테고리의 다른 글

Portainer에서 remote 도커 서버 추가  (0) 2022.01.27
Portainer 설치  (0) 2022.01.26
Docker-compose 설치  (0) 2022.01.26
Docker 실습-2탄  (0) 2022.01.26
Docker 실습-1탄  (0) 2022.01.26