[Docker] Ubuntu에 도커 설치하기

아현·2022년 12월 21일
0

Kubernetes

목록 보기
1/9

출처

업데이트 및 HTTP 패키지 설치


$ sudo apt install curl
$ sudo apt update
$ sudo apt-get install -y ca-certificates \ 
    curl \
    software-properties-common \
    apt-transport-https \
    gnupg \
    lsb-release



GPG 키 및 저장소 추가


$ sudo mkdir -p /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

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



도커 엔진 설치


  • docker는 CE(Community Edition)과 EE(Enterprise Edition)으로 나뉜다.

    • EE는 유료로 제공되는 기업용 솔루션이다. 일반적으로 무료인 CE 버전을 사용해도 핵심적인 컨테이너 기술은 동일하다.
  • 아래의 커맨드는 패키지가 제공하는 latest 버전의 도커 엔진과 컨테이너 데몬 서비스를 설치한다.


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



설치 확인


sudo docker version

Client: Docker Engine - Community
 Version:           20.10.22
 API version:       1.41
 Go version:        go1.18.9
 Git commit:        3a2c30b
 Built:             Thu Dec 15 22:28:02 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.22
  API version:      1.41 (minimum version 1.12)

...



컨테이너 실행


  • hello-world 컨테이너를 시험 실행하여 도커 엔진 설치를 확인한다. --rm 명령어를 주어 컨테이너 실행 후 바로 삭제되도록 한다.

sudo docker run --rm hello-world

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




profile
For the sake of someone who studies computer science

0개의 댓글