포스트 목록

2020년 4월 5일 일요일

[Kubernetes] Ubuntu에 도커 설치

Ubuntu에도 도커를 설치하기 위해 문서를 찾아보던 중 https://docs.docker.com/install/linux/docker-ce/ubuntu/ 에 잘 정리가 되어있어 요약, 번역하여 가져와 봤습니다.

Ubuntu 뿐만 아니라 CentOS, Debian, Fedora, Binaries 등 다른 Linux에 대해서도 나와있으니 잘 살펴보시면 좋겠습니다.

1. 오래된 버전을 삭제합니다. 저의 경우 오래된 버전이 없기 때문에 아래와 같이 지울 게 없다는 메시지가 나왔습니다.
$ sudo apt-get remove docker docker-engine docker.io containerd runc

2. 도커 엔진을 설치하기 전에 apt 업데이트를 진행합니다.
$ sudo apt-get update

3. 다음의 패키지를 설치합니다.
$ sudo apt-get install apt-transport-https ca-certificates curl \
gnupg-agent software-properties-common

4. 도커의 공식 GPG 키를 추가합니다.
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

4-1. 다음의 명령어를 수행하면 키가 추가된 것을 확인할 수 있습니다.
$ 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) 
sub   rsa4096 2017-02-22 [S]

4-2. 다음의 레파지토리를 추가해줍니다.
$ sudo add-apt-repository \
    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) \
    stable"

5. 도커 엔진을 설치합니다.
$ sudo apt-get install docker-ce docker-ce-cli containerd.io

6. 도커가 정상 설치됐는지 다음 명령을 통해 확인해 봅니다.
$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
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/

감사합니다.