본문 바로가기
프로그래밍 팁/서버, 백엔드

Ubuntu에서 5분만에 Docker를 설치하는 방법

by Archivers 2021. 7. 18.

 

 

도커(Docker)를 설치하는 방법 중에는 스크립트 방식(curl -fsSL https://get.docker.com -o get-docker.sh)이 있습니다. 이 방식은 개발 환경에 간단하게 설치해서 테스트해 보는 용도로는 적합하지만 프로덕션 용으로는 적합하지 않습니다. 이번 포스팅에선 스크립트로 설치하는 방식 대신에 실제 프로덕션 환경에서 사용하기 적합한 리포지터리를 통한 설치 방식을 알아보겠습니다.

설치 방법

1. 리포지터리 설정

다음의 명령어를 순차적으로 실행해서 필요한 패키지를 설치합니다.

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y

패키지 설치가 완료되면 다음 명령어를 실행해서 GPG 키를 추가해 줍니다.

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

그 이후 아래의 명령어를 실행해서 stable 버전 리포지터리를 설정합니다.

echo \
  "deb [arch=amd64 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

2. 도커 엔진 설치하기

리포지터리가 추가되었으니 다시 update 명령어를 통해 최신화하고 필요한 패키지를 인스톨하기 위해 다음의 명령어들을 순차적으로 입력합니다.

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

패키지 설치가 완료되었다면 다음의 명령어로 설치가 정상적으로 진행되었는지 확인합니다.

sudo docker run hello-world

명령어를 실행했을 때 도커가 hello-world:latest 이미지를 pull 받아서 Hello from Docker! This message shows that your installation appears to be working correctly.로 시작하는 메시지를 표시하면 정상적으로 설치가 된 것입니다.

 

 

참조: https://docs.docker.com/engine/install/ubuntu/

댓글