AWS EC2 인스턴스(Ubuntu 18.04 LTS)에 Docker CE 설치
Ubuntu Server 18.04 LTS를 실행하는 AWS EC2 인스턴스에 Docker CE 설치
신규 Host Machine에 처음으로 Docker CE을 설치하기 전에, Docker Repository 설정이 필요하다. 이후에 Repository로부터 Docker를 설치 및 업데이트할 수 있다.
사전 조건
- Ubuntu Server 18.04 LTS AMI를 사용하여 AWS EC2 인스턴스가 시작되어 있어야 한다.
Amazon EC2 인스턴스 연결
- AWS Management 콘솔에 로그인한 다음, EC2 콘솔을 연다.
- 좌측 탐색 창에서 인스턴스를 선택한다.
- 인스턴스 목록에서 연결할 인스턴스를 체크한 다음, 연결 버튼을 클릭한다.
- "인스턴스에 연결" 창에서 연결 방법 섹션의 독립 실행형 SSH 클라이언트를 선택한다. 이후 인스턴스 액세스 방법 섹션의 설명대로 진행한다.
Terminal에서 아래 명령을 실행하여 EC2 인스턴스에 연결한다.
chmod 400 gitlab-poc.pem
ssh -i "gitlab-poc.pem" ubuntu@[EC2-Instance-Public-DNS]
Repository 구성
apt 패키지 인덱스를 업데이트한다.
$ sudo apt-get update
Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:4 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Fetched 252 kB in 1s (218 kB/s)
Reading package lists... Done
apt가 HTTPS을 통해 repository를 사용할 수 있도록 필요한 패키지들을 설치한다.
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
ca-certificates is already the newest version (20190110~18.04.1).
ca-certificates set to manually installed.
The following additional packages will be installed:
libcurl4 python3-software-properties
The following NEW packages will be installed:
apt-transport-https gnupg-agent
The following packages will be upgraded:
curl libcurl4 python3-software-properties software-properties-common
4 upgraded, 2 newly installed, 0 to remove and 20 not upgraded.
Need to get 6572 B/413 kB of archives.
After this operation, 196 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 apt-transport-https all 1.6.12ubuntu0.1 [1692 B]
Get:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 gnupg-agent all 2.2.4-1ubuntu1.2 [4880 B]
Fetched 6572 B in 0s (35.3 kB/s)
Selecting previously unselected package apt-transport-https.
(Reading database ... 57084 files and directories currently installed.)
Preparing to unpack .../0-apt-transport-https_1.6.12ubuntu0.1_all.deb ...
Unpacking apt-transport-https (1.6.12ubuntu0.1) ...
Preparing to unpack .../1-curl_7.58.0-2ubuntu3.10_amd64.deb ...
Unpacking curl (7.58.0-2ubuntu3.10) over (7.58.0-2ubuntu3.9) ...
Preparing to unpack .../2-libcurl4_7.58.0-2ubuntu3.10_amd64.deb ...
Unpacking libcurl4:amd64 (7.58.0-2ubuntu3.10) over (7.58.0-2ubuntu3.9) ...
Selecting previously unselected package gnupg-agent.
Preparing to unpack .../3-gnupg-agent_2.2.4-1ubuntu1.2_all.deb ...
Unpacking gnupg-agent (2.2.4-1ubuntu1.2) ...
Preparing to unpack .../4-software-properties-common_0.96.24.32.14_all.deb ...
Unpacking software-properties-common (0.96.24.32.14) over (0.96.24.32.13) ...
Preparing to unpack .../5-python3-software-properties_0.96.24.32.14_all.deb ...
Unpacking python3-software-properties (0.96.24.32.14) over (0.96.24.32.13) ...
Setting up apt-transport-https (1.6.12ubuntu0.1) ...
Setting up libcurl4:amd64 (7.58.0-2ubuntu3.10) ...
Setting up python3-software-properties (0.96.24.32.14) ...
Setting up gnupg-agent (2.2.4-1ubuntu1.2) ...
Setting up software-properties-common (0.96.24.32.14) ...
Setting up curl (7.58.0-2ubuntu3.10) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for dbus (1.12.2-1ubuntu1.2) ...
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
Docker의 공식 GPG 키를 추가한다.
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK
Fingerprint(지문)의 마지막 8자를 검색하여, Fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88이 있는 키가 있는지 확인한다.
$ sudo apt-key fingerprint 0EBFCD88
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <docker@docker.com>
sub rsa4096 2017-02-22 [S]
Stable Repository(안정 버전 저장소)를 설정하기 위해 아래 명령어를 사용한다.
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:4 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Get:5 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages [12.5 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Fetched 329 kB in 1s (286 kB/s)
Reading package lists... Done
공식 Docker 저장소로부터 설치하는 것인지 확인한다.
$ sudo apt-cache policy docker-ce
docker-ce:
Installed: (none)
Candidate: 5:19.03.12~3-0~ubuntu-bionic
Version table:
5:19.03.12~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:19.03.11~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:19.03.10~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:19.03.9~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:19.03.8~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:19.03.7~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:19.03.6~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:19.03.5~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:19.03.4~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:19.03.3~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:19.03.2~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:19.03.1~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:19.03.0~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:18.09.9~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:18.09.8~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:18.09.7~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:18.09.6~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:18.09.5~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:18.09.4~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:18.09.3~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:18.09.2~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:18.09.1~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
5:18.09.0~3-0~ubuntu-bionic 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
18.06.3~ce~3-0~ubuntu 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
18.06.2~ce~3-0~ubuntu 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
18.06.1~ce~3-0~ubuntu 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
18.06.0~ce~3-0~ubuntu 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
18.03.1~ce~3-0~ubuntu 500
500 https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
docker-ce가 설치되지 않았으며 설치 후보는 공식 저장소에서 가져 왔다는 것을 알 수 있다.