Docker 설치 on Ubuntu

Ubuntu에서 Docker 설치 방법 정리. 기본적으로 Ubuntu Community에서 제공하는 docker.io가 존재하나, Docker.ce를 설치하는 것을 모두 권장하는 듯. Docker는 64bit 운영체계만 지원함.

먼저 기존 설치된 docker 관련 패키지들을 모두 제거.

$ sudo apt-get remove docker docker-engine docker.io containerd runc

또한 /var/lib/docker 안에, 기존에 설치했던 이미지, 컨테이너 등등의 파일이 존재하므로, 필요가 없다면 이것도 삭제하는 것을 권장함.

다음으로, 설치에 필요한 패키지 설치

$ sudo apt-get install ca-certificates curl gnupg lsb-release

Docker Repository GPG Key 등록

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Docker Repository를 apt 소스 리스트에 등록.

$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

설치 시작

$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io

설치한 이후 동작 테스트.

$ sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:aa0cc8055b82dc2509bed2e19b275c8f463506616377219d9642221ab53cf9fe
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/

실행 시 sudo를 사용하지 않고 이용하려면, 사용자 계정을 docker 그룹에 추가하면 됨.

$ sudo groupadd docker
$ sudo usermod -aG docker $USER

재부팅 후 사용 가능.


Comments

One response to “Docker 설치 on Ubuntu”

  1. […] Docker >= 19.03 (도커 설치 과정) […]

Leave a Reply

Your email address will not be published. Required fields are marked *