나에게 필요한 도커 설치하기
목차
요구사항
이 글은 다양한 환경에서 내게 필요한 버전의 도커 설치법을 설명합니다. 🎉
도커에 대해 이해가 부족하시다면 이 글 을 먼저 읽는 걸 추천합니다!
도커를 설치하기 전에 환경을 필요한 점검해 봅시다.
OS
- Windows
- Ubuntu
- CentOS
- 이 외에 Debian, Fedora 기반 linux, Mac
(장비를 보유하고, 테스트 할 수 있으면 추가로 작성하겠습니다)
Storage Driver
- overlay2 (권장)
- aufs
- btrfs
Architecture
- x86_64
- amd64
- arm64
Ubuntu docker 설치
- 이전 버전 확인 & 제거
이미 도커가 설치되어 있다면, 다시 설치할 필요가 없겠죠? :D
# Ubuntu
$ sudo apt-get remove docker docker-engine docker.io containerd runc
- 레포지토리 설정
도커를 설치하고 업데이트 하기 위해 필요한 repository 위치를 설정해야 합니다.
repository 위치를 설정해 주기 위해 필요한 기본 라이브러리를 설치해 줍시다.
# Ubuntu
$ sudo apt-get update
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
HTTPS를 통해 repository를 사용할 수 있게 해줍니다
필요한 패키지를 설치했으면 도커의 official GPG key를 추가해 줍시다.(Ubuntu만)
# Ubuntu
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
| sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
다음 명령어로 stable repository를 설정합니다. nightly나 test repository를 사용하기 위해서는 stable 다음에
nightly, test를 추가합니다.
아키텍처를 설정할 때엔 arch 다음에 amd64, armhf, arm64를 변경합니다.
# Ubuntu x86_64/amd64
$ 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
여기 에서 버전과 nightly 지원을 확인할 수 있습니다
- 도커 설치
repository를 추가했으니 apt를 업데이트 하고 설치합니다.
# Ubuntu
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
특정 버전을 설치하기 위해선 다음과 같이 합니다.
a. repo에서 가능한 버전을 리스트 합니다.
# Ubuntu
$ apt-cache madison docker-ce
docker-ce | 5:20.10.6-3-0-ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.5-3-0-ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
docker-ce | 5:20.10.4-3-0-ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
... 생략 ...
b. VERSION_STRING을 사용하여 특정 버전을 설치 합니다.
# Ubuntu
$ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
설치가 완료되었으면 확인해 봅시다. 😊
$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
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/
CentOS docker 설치
- 이전 버전 확인 & 제거
설마 apt가 없는 걸 확인하고 오셨나요...?
# CentOS
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
- 레포지토리 설정
도커를 설치하고 업데이트 하기 위해 필요한 repository 위치를 설정해야 합니다.
repository 위치를 설정해 주기 위해 필요한 기본 라이브러리를 설치해 줍시다.
# CentOS
$ sudo yum install -y yum-utils
CentOS에서 nightly나 test repository를 사용하기 위해서는 --enable 옵션에 docker-ce-nightly
또는 docker-ce-test를 추가해 줍니다.
# CentOS
$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
여기 에서 버전과 nightly 지원을 확인할 수 있습니다
- 도커 설치
도커 최신 버전을 설치하려면 다음 명령어를 입력합니다.
# CentOS
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
특정 버전을 설치하기 위해선 다음과 같이 합니다.
a. repo에서 가능한 버전을 리스트 합니다.
# CentOS
$ yum list docker-ce --showduplicates | sort -r
... 전략 ...
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
Loaded plugins: fastestmirror, langpacks
Installed Packages
Determining fastest mirrors
Available Packages
* updates: mirror.kakao.com
* extras: mirror.kakao.com
* epel: ftp.iij.ad.jp
* centos-sclo-sclo: mirror.kakao.com
* centos-sclo-rh: mirror.kakao.com
* base: mirror.kakao.com
b. VERSION_STRING을 사용하여 특정 버전을 설치 합니다.
예를 들면 docker-ce-17.03.0입니다.
# CentOS
$ sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
3. 도커 시작
# CentOS
$ sudo systemctl start docker
설치가 완료되었으면 확인해 봅시다. 😊
$ sudo docker run hello-world
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/