본문 바로가기

Docker

Ubuntu에 Docker 설치하기

1. Http 패키지 설치

HTTPS를 통해 저장소를 사용할 수 있도록 패키지 설치합니다. 

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

2. Docker의 공식 GPG key 등록

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

3. stable repository 설정

다음 명령을 사용하여 stable repository를 설정합니다. 'nightly' 또는 'test' 저장소를 추가하려면 아래 명령에서 stable 뒤에 nightly 또는 test(또는 둘 다)를 추가합니다. 

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

4. Docker Engine 설치

먼저 설치 가능 리스트를 최신화합니다.

sudo apt update

기본 설치

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

특정 버전 설치

  • 저장소에서 설치 가능한 엔진 버전을 조회합니다. 
apt-cache madison docker-ce

  • 조회한 결과 중에서 설치를 원하는 버전을 설치합니다. 
sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io

설치 확인

hello-world 이미지를 실행하여 Docker 엔진이 올바르게 설치되었는지 확인합니다. 

sudo docker run hello-world