본문 바로가기

DEV/ubuntu

Ubuntu docker 설치

업데이트 및 HTTP 패키지 설치

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

GPG 키 및 저장소 추가

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

Repository 등록

 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

최신 버전 설치

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

특정 버전 설치

sudo apt-get install docker-ce=5:20.10.14~3-0~ubuntu-focal docker-ce-cli=5:20.10.14~3-0~ubuntu-focal containerd.io

Docker 실행권한 부여

sudo usermod -aG docker

Docker 설치 확인

docker --version

Docker Compose 설치

compose 설치

원하는 version을 설치하고 싶으면, v2.5.0 대신 버전 명시

sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

실행권한 부여

sudo chmod +x /usr/local/bin/docker-compose

Docker-compose 설치 확인

docker-compose --version