Recommanded Free YOUTUBE Lecture: <% selectedImage[1] %>

Contents

도커 설치하기

우분투 리눅스 17.10에서 설치한다. 우분투 리눅스의 패키지관리자를 이용해서 docker를 설치할 수 있기는 한데, 권장하지 않는다. 도커 공식 레포지토리에서 설치하는 걸 권장한다.

apt 패키지 색인을 갱신한다.
$ sudo apt-get update

원할한 설치를 위해서 몇 개 필요한 패키지들을 우선 설치한다.
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

도커의 GPG 키를 등록한다.
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK

도커 레포지토리를 등록한다.
$ sudo add-apt-repository \
    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) \
    stable"
$ sudo apt-get update

gpg 키를 검증해 보자.
$ sudo apt-key fingerprint 0EBFCD88

pub   4096R/0EBFCD88 2017-02-22
      Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid                  Docker Release (CE deb) <docker@docker.com>
sub   4096R/F273FCD8 2017-02-22

docker-ce(Community Edition)과 docker-ee(Enterprise Edition)이 있다. 생각없이 ce 버전 사용하기로 했다.
$ sudo apt-get install docker-ce

도커 버전을 확인해 보자.
$ docker version
Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Wed Jun 20 21:43:51 2018
 OS/Arch:      linux/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Wed Jun 20 21:42:00 2018
  OS/Arch:      linux/amd64
  Experimental: false

도커는 "hello-world" 라는 테스트 목적의 도커 이미지를 제공한다. 이 이미지를 이용해서 컨테이너를 실행해 보자.
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9db2ca6ccae0: Pull complete 
Digest: sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.
"Hello from Docker!" 메시지가 보이면 성공.

도커 제거하기

도커 패키지를 삭제한다.
$ sudo apt-get purge docker-ce
도커를 운영하면서 만들어진 컨테이너, 볼륨, 설정파일등은 패키지 관리자로 삭제 할 수 없다. 직접 삭제해줘야 한다.
$ sudo rm -rf /var/lib/docker