728x90

AWS EC2에 만든 ubuntu서버에 docker 및 docker compose를 설치해보겠습니다.

 

먼저 생성한 ec2에 연결합니다.

> ssh -i "***.pem" ubuntu@ec2-***.ap-northeast-2.compute.amazonaws.com
The authenticity of host '***.ap-northeast-2.compute.amazonaws.com (xx.xxx.x.xxx)' can't be established.
ECDSA key fingerprint is SHA256:PcvcASLF420AQzOU5mzhCdy6D8OMMORUd29bpT6w0a8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'ec2-***.ap-northeast-2.compute.amazonaws.com,xx.xxx.x.xxx' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 22.04 LTS (GNU/Linux 5.15.0-1004-aws x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Mon May 16 05:03:46 UTC 2022

  System load:  0.146484375       Processes:             105
  Usage of /:   5.0% of 28.90GB   Users logged in:       0
  Memory usage: 20%               IPv4 address for eth0: xxx.xx.xx.xxx
  Swap usage:   0%

0 updates can be applied immediately.


The list of available updates is more than a week old.
To check for new updates run: sudo apt update


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@ip-:~$

yes를 입력하여 접속하니, ec2를 처음 생성하여 위와 같이 뜹니다.

sudo apt-get update를 실행합니다.

ubuntu@ip-:~$  sudo apt-get update
Hit:1 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease
Get:4 https://download.docker.com/linux/ubuntu jammy InRelease [48.9 kB]
Get:5 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages [5109 B]
Hit:6 http://security.ubuntu.com/ubuntu jammy-security InRelease
Fetched 54.0 kB in 0s (114 kB/s)
Reading package lists... Done

 

apt 패키지 index를 업데이트하고 https를 통해 repository를 이용하기 위해 다음과 같이 설치합니다.

ubuntu@ip-:~$ sudo apt-get install -y ca-certificates \
    curl \
    software-properties-common \
    apt-transport-https \
    gnupg \
    lsb-release
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package
curl: (6) Could not resolve host: software-properties-common
curl: (6) Could not resolve host: apt-transport-https
curl: (6) Could not resolve host: gnupg
curl: (6) Could not resolve host: lsb-release

 

docker의 official GPG key를 등록합니다.

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

stable repository를 등록합니다.

ubuntu@ip-:~$  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-get install docker-ce docker-ce-cli containerd.io 명령어로 docker Engine을 설치합니다.

ubuntu@ip-:~$ sudo apt-get install docker-ce docker-ce-cli containerd.io
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  docker-ce-rootless-extras docker-scan-plugin libltdl7 libslirp0 pigz slirp4netns
Suggested packages:
  aufs-tools cgroupfs-mount | cgroup-lite
The following NEW packages will be installed:
  containerd.io docker-ce docker-ce-cli docker-ce-rootless-extras docker-scan-plugin libltdl7 libslirp0 pigz
  slirp4netns
0 upgraded, 9 newly installed, 0 to remove and 28 not upgraded.
Need to get 102 MB of archives.
After this operation, 422 MB 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 jammy/universe amd64 pigz amd64 2.6-1 [63.6 kB]
Get:2 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy/main amd64 libltdl7 amd64 2.4.6-15build2 [39.6 kB]
Get:3 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy/main amd64 libslirp0 amd64 4.6.1-1build1 [61.5 kB]
Get:4 http://ap-northeast-2.ec2.archive.ubuntu.com/ubuntu jammy/universe amd64 slirp4netns amd64 1.0.1-2 [28.2 kB]
Get:5 https://download.docker.com/linux/ubuntu jammy/stable amd64 containerd.io amd64 1.6.4-1 [28.1 MB]
Get:6 https://download.docker.com/linux/ubuntu jammy/stable amd64 docker-ce-cli amd64 5:20.10.16~3-0~ubuntu-jammy [40.6 MB]
Get:7 https://download.docker.com/linux/ubuntu jammy/stable amd64 docker-ce amd64 5:20.10.16~3-0~ubuntu-jammy [21.0 MB]
Get:8 https://download.docker.com/linux/ubuntu jammy/stable amd64 docker-ce-rootless-extras amd64 5:20.10.16~3-0~ubuntu-jammy [8167 kB]
Get:9 https://download.docker.com/linux/ubuntu jammy/stable amd64 docker-scan-plugin amd64 0.17.0~ubuntu-jammy [3521 kB]
Fetched 102 MB in 3s (32.3 MB/s)
Selecting previously unselected package pigz.
(Reading database ... 63599 files and directories currently installed.)
Preparing to unpack .../0-pigz_2.6-1_amd64.deb ...
Unpacking pigz (2.6-1) ...
Selecting previously unselected package containerd.io.
Preparing to unpack .../1-containerd.io_1.6.4-1_amd64.deb ...
Unpacking containerd.io (1.6.4-1) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../2-docker-ce-cli_5%3a20.10.16~3-0~ubuntu-jammy_amd64.deb ...
Unpacking docker-ce-cli (5:20.10.16~3-0~ubuntu-jammy) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../3-docker-ce_5%3a20.10.16~3-0~ubuntu-jammy_amd64.deb ...
Unpacking docker-ce (5:20.10.16~3-0~ubuntu-jammy) ...
Selecting previously unselected package docker-ce-rootless-extras.
Preparing to unpack .../4-docker-ce-rootless-extras_5%3a20.10.16~3-0~ubuntu-jammy_amd64.deb ...
Unpacking docker-ce-rootless-extras (5:20.10.16~3-0~ubuntu-jammy) ...
Selecting previously unselected package docker-scan-plugin.
Preparing to unpack .../5-docker-scan-plugin_0.17.0~ubuntu-jammy_amd64.deb ...
Unpacking docker-scan-plugin (0.17.0~ubuntu-jammy) ...
Selecting previously unselected package libltdl7:amd64.
Preparing to unpack .../6-libltdl7_2.4.6-15build2_amd64.deb ...
Unpacking libltdl7:amd64 (2.4.6-15build2) ...
Selecting previously unselected package libslirp0:amd64.
Preparing to unpack .../7-libslirp0_4.6.1-1build1_amd64.deb ...
Unpacking libslirp0:amd64 (4.6.1-1build1) ...
Selecting previously unselected package slirp4netns.
Preparing to unpack .../8-slirp4netns_1.0.1-2_amd64.deb ...
Unpacking slirp4netns (1.0.1-2) ...
Setting up docker-scan-plugin (0.17.0~ubuntu-jammy) ...
Setting up containerd.io (1.6.4-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up libltdl7:amd64 (2.4.6-15build2) ...
Setting up docker-ce-cli (5:20.10.16~3-0~ubuntu-jammy) ...
Setting up libslirp0:amd64 (4.6.1-1build1) ...
Setting up pigz (2.6-1) ...
Setting up docker-ce-rootless-extras (5:20.10.16~3-0~ubuntu-jammy) ...
Setting up slirp4netns (1.0.1-2) ...
Setting up docker-ce (5:20.10.16~3-0~ubuntu-jammy) ...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3) ...
Scanning processes...
Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

 

설치 완료docker --version으로 버전을 확인합니다.

ubuntu@ip-:~$ docker --version
Docker version 20.10.16, build aa7e414

 

다음으로 docker compose를 설치합니다.

docker compose는 docker설치 시 함께 설치되지 않으므로 별도로 설치해주어야 하며, 여러 개의 도커 애플리케이션 컨테이너들을 정의하고 실행할 수 있도록 해줍니다. yaml파일을 사용하여 서비스를 설정하고 하나의 커맨드만으로 여러 개의 도커 컨테이너들을 사용할 수 있습니다.

ubuntu@ip-:~$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 12.1M  100 12.1M    0     0  14.7M      0 --:--:-- --:--:-- --:--:-- 44.4M

 

실행 권한을 부여합니다.

ubuntu@ip-:~$ sudo chmod +x /usr/local/bin/docker-compose

 

docker compose 또한 docker-compse --version 명령을 통해 잘 설치되었는지 확인해봅니다.

ubuntu@ip-:~$ docker-compose --version
docker-compose version 1.29.2, build 5becea4c

 

728x90
반응형

+ Recent posts