Ubuntu 22.04 Docker 설치하기

Docker는 컨테이너 기반의 가상화를 제공하여 소프트웨어를 효율적으로 개발, 배포, 실행할 수 있게 도와주는 도구이다. 이 글에서는 Ubuntu 22.04에 Docker를 설치하는 방법에 대해 알아본다.

Docker 설치

1. 패키지 업데이트

먼저 시스템의 패키지 목록을 업데이트한다.

sudo apt update

2. 필요한 패키지 설치

Docker를 설치하기 위해 필요한 몇 가지 패키지를 설치한다.

sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

3. Docker GPG 키 추가

Docker의 공식 GPG 키를 시스템에 추가한다.

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

4. Docker 저장소 추가

Docker의 공식 저장소를 apt에 추가한다.

echo "deb [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

5. Docker 설치

이제 Docker를 설치한다.

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

6. Docker 사용자 그룹에 추가 (옵션)

Docker 명령을 sudo 없이 실행하려면 현재 사용자를 docker 그룹에 추가한다.

sudo usermod -aG docker $USER

로그아웃 후 다시 로그인하면 변경이 적용된다.

Docker 동작 확인

설치가 완료되었다면, 간단한 컨테이너를 실행하여 Docker가 정상적으로 동작하는지 확인할 수 있다.

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:ac69084025c660510933cca701f615283cdbb3aa0963188770b54c31c8962493
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/

참고 사이트

This Post Has 2 Comments

  1. ddfdddggdf

    설치 명령어 잘못 입력됐네용

답글 남기기