Linux,Unix,BSD

Docker 설치하기 on CentOS7 (without internet)

채윤아빠 2019. 5. 24. 10:42
728x90
반응형



Docker RPM 파일 준비

외부 인터넷을 활용할 수 없는 네트워크 환경에서, rpm 패키지 파일들을 이용하여 Docker를 설치하는 방법을 정리한 문서입니다.

운영환경 : CentOS 7.6 / DMZ와 유사하게 특정 대역 등에서만 접속이 가능한 네트워크 환경

외부 인터넷을 사용할 수 있는 동일한 CentOS 7.6 장비 또는 VM에서 아래와 같이 Docker 설치를 위하여 필요한 rpm 패키지 파일들을 다운로드 받은 후, 운영할 장비에 rpm 패키지 파일들을 업로드하여 수동으로 설치합니다.

Docker 레포지토리를 위한 yum-utils 및 기본 도구 설치

Docker 레포지토리를 위하여 필요한 패키지 파일 다운로드하고 설치합니다.

$ yum install -y yum-utils device-mapper-persistent-data lvm2 --downloadonly --downloaddir=/root/rpms/yum-utils
$ cd /root/rpms/yum-utils
$ rpm -Uvh --replacepkgs *rpm
warning: device-mapper-1.02.158-2.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:device-mapper-libs-7:1.02.158-2.e################################# [  6%]
   2:device-mapper-7:1.02.158-2.el7   ################################# [ 11%]
   3:device-mapper-event-libs-7:1.02.1################################# [ 17%]
   4:device-mapper-event-7:1.02.158-2.################################# [ 22%]
   5:lvm2-libs-7:2.02.185-2.el7       ################################# [ 28%]
   6:python-chardet-2.2.1-3.el7       ################################# [ 33%]
   7:python-kitchen-1.1.1-5.el7       ################################# [ 39%]
   8:libxml2-python-2.9.1-6.el7_2.3   ################################# [ 44%]
   9:device-mapper-persistent-data-0.8################################# [ 50%]
  10:lvm2-7:2.02.185-2.el7            ################################# [ 56%]
  11:yum-utils-1.1.31-52.el7          ################################# [ 61%]
Cleaning up / removing...
  12:lvm2-7:2.02.180-8.el7            ################################# [ 67%]
  13:lvm2-libs-7:2.02.180-8.el7       ################################# [ 72%]
  14:device-mapper-event-7:1.02.149-8.################################# [ 78%]
  15:device-mapper-event-libs-7:1.02.1################################# [ 83%]
  16:device-mapper-libs-7:1.02.149-8.e################################# [ 89%]
  17:device-mapper-7:1.02.149-8.el7   ################################# [ 94%]
  18:device-mapper-persistent-data-0.7################################# [100%]

Docker를 위한 레포지토리 설정

"yum-config-manager" 도구를 이용하여 Docker를 위한 레포지토리를 추가합니다.

$ yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
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

위와 같이 Docker를 위한 레포지토리가 추가되면, Docker rpm 패키지 파일들을 다운로드 받을 수 있습니다.

Docker rpm 패키지 파일 다운로드

Docker를 위한 레포지토리 추가 후, 다음과 같이 Docker rpm 패키지 파일들을 다운로드 받습니다.

$ yum install docker-ce docker-ce-cli containerd.io --downloadonly --downloaddir=/root/rpms/docker-19.03.2-3
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: data.aonenetworks.kr
 * extras: data.aonenetworks.kr
 * updates: data.aonenetworks.kr
Resolving Dependencies

Dependencies Resolved

======================================================================================================================================================================
 Package                                        Arch                           Version                                 Repository                                Size
======================================================================================================================================================================
Installing:
 containerd.io                                  x86_64                         1.2.6-3.3.el7                           docker-ce-stable                          26 M
 docker-ce                                      x86_64                         3:19.03.2-3.el7                         docker-ce-stable                          24 M
 docker-ce-cli                                  x86_64                         1:19.03.2-3.el7                         docker-ce-stable                          39 M
Installing for dependencies:
 audit-libs-python                              x86_64                         2.8.5-4.el7                             base                                      76 k
 checkpolicy                                    x86_64                         2.5-8.el7                               base                                     295 k
 container-selinux                              noarch                         2:2.107-3.el7                           extras                                    39 k
 libcgroup                                      x86_64                         0.41-21.el7                             base                                      66 k
 libseccomp                                     x86_64                         2.3.1-3.el7                             base                                      56 k
 libsemanage-python                             x86_64                         2.5-14.el7                              base                                     113 k
 policycoreutils-python                         x86_64                         2.5-33.el7                              base                                     457 k
 python-IPy                                     noarch                         0.75-6.el7                              base                                      32 k
 setools-libs                                   x86_64                         3.3.8-4.el7                             base                                     620 k
Updating for dependencies:
 audit                                          x86_64                         2.8.5-4.el7                             base                                     256 k
 audit-libs                                     x86_64                         2.8.5-4.el7                             base                                     102 k
 policycoreutils                                x86_64                         2.5-33.el7                              base                                     916 k

Transaction Summary
======================================================================================================================================================================
Install  3 Packages (+9 Dependent packages)
Upgrade             ( 3 Dependent packages)

Total download size: 93 M

rpm 패키지 파일 업로드

다음과 같이 다운로드 받은 rpm 패키지 파일들을 운영할 서버로 업로드 합니다.

$ cd /root/rpms
$ tar cf yum-utils-20191005.tar yum-utils/
$ tar cf docker-20191005.tar docker/
$ scp -P1022 /root/rpms/yum-utils-20191005.tar root@172.16.112.70:/home/nfs/backup/rpms
$ scp -P1022 /root/rpms/docker-20191005.tar root@172.16.112.70:/home/nfs/backup/rpms

패키지 설치 (운영 서버)

yum-utils 및 기본 도구 설치

다음과 같이 yum-utils 및 기본 도구 패키지 tar 파일을 풀고, 설치합니다.

$ cd /home/nfs/backup/rpms/
$ tar xf yum-utils-20191005.tar
$ cd /home/nfs/backup/rpms/yum-utils
$ rpm -Uvh --replacepkgs *rpm
warning: device-mapper-1.02.158-2.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:device-mapper-libs-7:1.02.158-2.e################################# [  6%]
   2:device-mapper-7:1.02.158-2.el7   ################################# [ 11%]
   3:device-mapper-event-libs-7:1.02.1################################# [ 17%]
   4:device-mapper-event-7:1.02.158-2.################################# [ 22%]
   5:lvm2-libs-7:2.02.185-2.el7       ################################# [ 28%]
   6:python-chardet-2.2.1-3.el7       ################################# [ 33%]
   7:python-kitchen-1.1.1-5.el7       ################################# [ 39%]
   8:libxml2-python-2.9.1-6.el7_2.3   ################################# [ 44%]
   9:device-mapper-persistent-data-0.8################################# [ 50%]
  10:lvm2-7:2.02.185-2.el7            ################################# [ 56%]
  11:yum-utils-1.1.31-52.el7          ################################# [ 61%]
Cleaning up / removing...
  12:lvm2-7:2.02.180-8.el7            ################################# [ 67%]
  13:lvm2-libs-7:2.02.180-8.el7       ################################# [ 72%]
  14:device-mapper-event-7:1.02.149-8.################################# [ 78%]
  15:device-mapper-event-libs-7:1.02.1################################# [ 83%]
  16:device-mapper-libs-7:1.02.149-8.e################################# [ 89%]
  17:device-mapper-7:1.02.149-8.el7   ################################# [ 94%]
  18:device-mapper-persistent-data-0.7################################# [100%]

Docker 패키지 설치

다음과 같이 업로드된 Docker rpm 패키지 tar 파일을 풀고, Docker 패키지를 설치합니다.

$ cd /home/nfs/backup/rpms/
$ tar xf docker-20191005.tar
$ cd /home/nfs/backup/rpms/docker
$ rpm -Uvh --replacepkgs *rpm
warning: containerd.io-1.2.6-3.3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:policycoreutils-2.5-29.el7_6.1   ################################# [  7%]
   2:libcgroup-0.41-20.el7            ################################# [ 14%]
   3:setools-libs-3.3.8-4.el7         ################################# [ 21%]
   4:python-IPy-0.75-6.el7            ################################# [ 29%]
   5:libsemanage-python-2.5-14.el7    ################################# [ 36%]
   6:libseccomp-2.3.1-3.el7           ################################# [ 43%]
   7:docker-ce-cli-1:19.03.2-3.el7    ################################# [ 50%]
   8:checkpolicy-2.5-8.el7            ################################# [ 57%]
   9:audit-libs-python-2.8.4-4.el7    ################################# [ 64%]
  10:policycoreutils-python-2.5-29.el7################################# [ 71%]
  11:container-selinux-2:2.107-1.el7_6################################# [ 79%]
  12:containerd.io-1.2.6-3.3.el7      ################################# [ 86%]
  13:docker-ce-3:19.03.2-3.el7        ################################# [ 93%]
Cleaning up / removing...
  14:policycoreutils-2.5-29.el7       ################################# [100%]

도커(Docker) 서비스 활성화

다음과 같이 도커(Docker) 서비스를 활성화하고, 도커(Docker) 서비스를 시작합니다.

$ systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
$ systemctl start docker

도커(Docker) 버전 확인

다음과 같이 도커(Docker)의 버전을 확인합니다.

$ docker version
 Version:           19.03.2
 API version:       1.40
 Go version:        go1.12.8
 Git commit:        6a30dfc
 Built:             Thu Aug 29 05:28:55 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.2
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.8
  Git commit:       6a30dfc
  Built:            Thu Aug 29 05:27:34 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Docker 시험하기

"hello-world" 이미지 받기

$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:0e11c388b664df8a27a901dce21eb89f11d8292f7fca1b3e3c4321bf7897bffe
Status: Downloaded newer image for hello-world:latest

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              fce289e99eb9        4 months ago        1.84kB

"hello-world" 이미지 실행하기

$ docker run --rm hello-world

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/

참고자료