June 16, 2019

Docker-ce Install Ubuntu 편

Docker-CE Install

Ubuntu에 Docker (도커) 설치

띠용!!
본글은 Linux Ubuntu 환경의 18.04버전의 64Bit 기반으로 진행합니다.

Description: Ubuntu 18.04
Release: 18.04
Codename : Disco Dingo




Ubuntu Docker-CE (Commnutity Edition) Installs

본 Docker 설치는 정식 도커 사이트 기반 설명대로 설치를 진행하고 있습니다. OS에 따라 설치 방법이 다르므로 Docker Docs를 참조 하시면 됩니당.

[패키지 업데이트]
dongdonge@dongdonge$ sudo apt-get update

도커 패키지를 설치하기전 먼저 apt 패키지 리스트를 업데이트 진행한다.



[패키지 설치]
dongdonge@dongdonge$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

apt가 HTTPS를 통해 저장소를 사용할 수 있도록 패키지를 설치한다.



[GPG Key 등록]
dongdonge@dongdonge$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Docker의 공식 GPG Key 등록 한다.



[GPG Key Check]
dongdonge@dongdonge$ sudo apt-key fingerprint 0EBFCD88

pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]

꼭 위 코드를 비교하여 GPG Key가 맞는지 체크 하자!!



[리포지토리 추가]
dongdonge@dongdonge$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
   
기존:1 https://download.docker.com/linux/ubuntu bionic InRelease
기존:2 http://kr.archive.ubuntu.com/ubuntu bionic InRelease
기존:3 http://kr.archive.ubuntu.com/ubuntu bionic-updates InRelease
기존:4 http://kr.archive.ubuntu.com/ubuntu bionic-backports InRelease
기존:5 http://security.ubuntu.com/ubuntu bionic-security InRelease
패키지 목록을 읽는 중입니다... 완료

Docker를 설치하기전 지포지토리를 추가한다. 이때 OS에 맞게 리포지토리를 추가해야 한다!! 현재 Ubuntu X64기준 이므로. 이외에 다른 OS 및 다른 비트일 경우 꼭!! 도커 Docs를 참조하자.



[패키지 업데이트]
dongdonge@dongdonge$ sudo apt-get update

[sudo] password for dongdonge:
기존:1 http://kr.archive.ubuntu.com/ubuntu bionic InRelease
기존:2 http://kr.archive.ubuntu.com/ubuntu bionic-updates InRelease
기존:3 http://kr.archive.ubuntu.com/ubuntu bionic-backports InRelease
기존:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
패키지 목록을 읽는 중입니다... 완료




[패키지 Docker 검색]
dongdonge@dongdonge$ sudo apt-cache search docker-ce

docker-ce-cli - Docker CLI: the open-source application container engine


dongdonge@dongdonge$ sudo apt-cache search containerd.io

containerd.io - An open and reliable container runtime

위 사진 [패키지 Docker 검색] 처럼 검색이 되어야 설치를 진행할 수 있다.
검색이 되었으므로 Docker를 설치하자!!



[Docker install]
dongdonge@dongdonge$ sudo apt-get install docker-ce

The following additional packages will be installed:
  aufs-tools cgroupfs-mount containerd.io docker-ce-cli pigz
다음 새 패키지를 설치할 것입니다:
  aufs-tools cgroupfs-mount containerd.io docker-ce docker-ce-cli pigz
0개 업그레이드, 6개 새로 설치, 0개 제거 및 472개 업그레이드 안 함.
50.7 M바이트 아카이브를 받아야 합니다.
이 작업 후 243 M바이트의 디스크 공간을 더 사용하게 됩니다.

Docker-ce를 설치한다. Docker를 설치할 때 아래 패키지와 함께 설치된다. [aufs-tools cgroupfs-mount containerd.io docker-ce docker-ce-cli pigz]



[Docker Test - Hello World!!]
dongdonge@dongdonge$ sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8
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" 이미지를 실행하여 Docker-CE가 올바르게 설치되었는지 확인하는 과정이다. 위 사진 처럼 진행이 되었다면 Docker가 정상적으로 설치가 된걸 볼 수 있다.!!





Docker Version 확인

  • docker version

dongdonge@dongdonge$ sudo docker version
Client:
 Version:           18.09.6
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        481bc77
 Built:             Sat May  4 02:35:57 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.6
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       481bc77
  Built:            Sat May  4 01:59:36 2019
  OS/Arch:          linux/amd64
  Experimental:     false

현재 우분투에 설치된 도커 버전은 18.09.6으로 설치된걸 확인할 수 있다.



Docker 환경 정보 확인

  • docker info

dongdonge@dongdonge$ sudo docker info
Containers: 2  # 컨테이너 갯수
 Running: 0
 Paused: 0
 Stopped: 2
Images: 1      # 이미지 갯수
Server Version: 18.09.6
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: bb71b10fd8f58240ca47fbb579b9d1028eea7c84
runc version: 2b18fe1d885ee5083ef9f0838fee39b62d653e30
init version: fec3683
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.15.0-29-generic
Operating System: Ubuntu 18.04.1 LTS
OSType: linux    # OS 종류
Architecture: x86_64   # 아키텍처
CPUs: 4
Total Memory: 3.83GiB
Name: dongdonge
ID: N7SH:X3FT:B4XC:LLSU:P6XL:URD3:77ZD:MZGV:CLEX:ZFQF:DIWC:KJD2
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

WARNING: No swap limit support




Docker Disk 용량 상황

  • docker system df

dongdonge@dongdonge$ sudo docker system df

TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              1                   1                   1.84kB              0B (0%)
Containers          2                   0                   0B                  0B
Local Volumes       0                   0                   0B                  0B
Build Cache         0                   0                   0B                  0B

dongdonge@dongdonge$ sudo docker system df -v

Images space usage:

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE                SHARED SIZE         UNIQUE SIZE         CONTAINERS
hello-world         latest              fce289e99eb9        5 months ago        1.84kB              0B                  1.84kB              2

Containers space usage:

CONTAINER ID        IMAGE               COMMAND             LOCAL VOLUMES       SIZE                CREATED             STATUS                         NAMES
0577097bb150        hello-world         "/hello"            0                   0B                  About an hour ago   Exited (0) About an hour ago   sad_wu
8fcac4525241        hello-world         "/hello"            0                   0B                  2 hours ago         Exited (0) 2 hours ago         jovial_cerf

Local Volumes space usage:

VOLUME NAME         LINKS               SIZE

Build cache usage: 0B

CACHE ID            CACHE TYPE          SIZE                CREATED             LAST USED           USAGE               SHARED

구체적인 정보를 확인하기 위해 -v 옵션을 사용한다.
출력 정보를 통해 이미지 사이즈(용량)를 확인할 수 있다.