안녕하세요 저번시간에 Container와 Docker에 대해서 간략하게 알아보는 시간을 가졌는데요.
(서버 환경 : Amazon Linux 2 , 서버 스펙 : t3.micro)
아무래도 엔지니어분들은 직접 명령어를 쳐야 몸이 풀리기때문에 도커 설치하는 법 부터 가져왔습니다!
자 한번 설치를 시작해볼까요???
1. 테스트 서버를 간만에 접속해서 업데이트를 먼저 해줍니다.
$ sudo yum -y upgrade
[ec2-user@ip-172-20-1-221 ~]$ sudo yum -y upgrade Loaded plugins: extras_suggestions, langpacks, priorities, update-motd amzn2-core | 2.4 kB 00:00:00 amzn2extra-docker | 1.3 kB 00:00:00 Resolving Dependencies --> Running transaction check ---> Package amazon-ssm-agent.x86_64 0:2.3.662.0-1.amzn2 will be updated ---> Package amazon-ssm-agent.x86_64 0:2.3.714.0-1.amzn2 will be an update ---> Package at.x86_64 0:3.1.13-23.amzn2 will be updated ... sysstat.x86_64 0:10.1.5-18.amzn2.0.1 systemd.x86_64 0:219-57.amzn2.0.12 systemd-libs.x86_64 0:219-57.amzn2.0.12 systemd-sysv.x86_64 0:219-57.amzn2.0.12 systemtap-runtime.x86_64 0:4.2-1.amzn2.0.1 tcpdump.x86_64 14:4.9.2-4.amzn2.1 yum.noarch 0:3.4.3-158.amzn2.0.3 Replaced: kpatch.noarch 0:0.4.0-3.amzn2 rpm-python.x86_64 0:4.11.3-25.amzn2.0.3 Complete!
2. Docker를 설치해볼차례!
$ sudo amazon-linux-extras install -y docker
[ec2-user@ip-172-20-1-221 ~]$ sudo amazon-linux-extras install -y docker Installing docker Loaded plugins: extras_suggestions, langpacks, priorities, update-motd Cleaning repos: amzn2-core amzn2extra-docker 10 metadata files removed 4 sqlite files removed 0 metadata files removed Loaded plugins: extras_suggestions, langpacks, priorities, update-motd amzn2-core | 2.4 kB 00:00:00 amzn2extra-docker | 1.3 kB 00:00:00 (1/4): amzn2-core/2/x86_64/updateinfo | 187 kB 00:00:00 (2/4): amzn2-core/2/x86_64/group_gz | 2.5 kB 00:00:00 ... =================================================================================================================================== Package Arch Version Repository Size =================================================================================================================================== Installing: docker x86_64 18.09.9ce-2.amzn2 amzn2extra-docker 30 M Installing for dependencies: containerd x86_64 1.2.6-1.amzn2 amzn2extra-docker 20 M libcgroup x86_64 0.41-21.amzn2 amzn2-core 66 k pigz x86_64 2.3.4-1.amzn2.0.1 amzn2-core 81 k runc x86_64 1.0.0-0.1.20190510.git2b18fe1.amzn2 amzn2extra-docker 2.0 M Transaction Summary =================================================================================================================================== Install 1 Package (+4 Dependent packages) Total download size: 51 M Installed size: 214 M Downloading packages: (1/5): libcgroup-0.41-21.amzn2.x86_64.rpm | 66 kB 00:00:00 (2/5): pigz-2.3.4-1.amzn2.0.1.x86_64.rpm | 81 kB 00:00:00 (3/5): containerd-1.2.6-1.amzn2.x86_64.rpm | 20 MB 00:00:00 (4/5): runc-1.0.0-0.1.20190510.git2b18fe1.amzn2.x86_64.rpm | 2.0 MB 00:00:00 (5/5): docker-18.09.9ce-2.amzn2.x86_64.rpm | 30 MB 00:00:00 ----------------------------------------------------------------------------------------------------------------------------------- Total 75 MB/s | 51 MB 00:00:00 ... [ =1.8.0_192 =1.8.0_202 =1.8.0_212 =1.8.0_222 =1.8.0_232 =1.8.0_242 ] 28 firecracker available [ =0.11 ] 29 golang1.11 available \ [ =1.11.3 =1.11.11 =1.11.13 ] 30 squid4 available [ =4 ] 31 php7.3 available \ [ =7.3.2 =7.3.3 =7.3.4 =7.3.6 =7.3.8 =7.3.9 =7.3.10 =7.3.11 =7.3.13 ] 32 lustre2.10 available [ =2.10.5 =2.10.8 ] 33 java-openjdk11 available [ =11 ] 34 lynis available [ =stable ] 35 kernel-ng available [ =stable ] 36 BCC available [ =0.x ] 37 mono available [ =5.x ] 38 nginx1 available [ =stable ] 39 ruby2.6 available [ =2.6 ] 40 mock available [ =stable ] 41 postgresql11 available [ =11 ] [ec2-user@ip-172-20-1-221 ~]$ # 버전확인 [ec2-user@ip-172-20-1-221 ~]$ docker --version Docker version 18.09.9-ce, build 039a7df [ec2-user@ip-172-20-1-221 ~]$
3. 설치를 했으니 돌려봅시다.
$ sudo systemctl start docker
[ec2-user@ip-172-20-1-221 ~]$ sudo systemctl start docker [ec2-user@ip-172-20-1-221 ~]$ ps -ef | grep docker root 22846 1 1 08:23 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --default-ulimit nofile=1024:4096 ec2-user 23025 4157 0 08:23 pts/0 00:00:00 grep --color=auto docker
4. ec2-user에게 권한을..
$ sudo usermod -aG docker ec2-user
[ec2-user@ip-172-20-1-221 ~]$ sudo systemctl start docker [ec2-user@ip-172-20-1-221 ~]$ ps -ef | grep docker root 22846 1 1 08:23 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --default-ulimit nofile=1024:4096 ec2-user 23025 4157 0 08:23 pts/0 00:00:00 grep --color=auto docker # 적용을 위하여 다시 ssh 재접속을 합니다 # exit로 나간뒤 접속 ㄱㄱ # sudo 명령어 없이 실행해봅니다. [ec2-user@ip-172-20-1-221 ~]$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [ec2-user@ip-172-20-1-221 ~]$
+ 번외로 docker는 Server-Client 구조입니다.
# docker verision으로 각각의 버전확인 가능 [kbseo@ip-172-20-1-221 ~]$ docker version Client: Version: 18.09.9-ce API version: 1.39 Go version: go1.10.3 Git commit: 039a7df Built: Fri Nov 1 19:26:49 2019 OS/Arch: linux/amd64 Experimental: false Server: Engine: Version: 18.09.9-ce API version: 1.39 (minimum version 1.12) Go version: go1.10.3 Git commit: 039a7df Built: Fri Nov 1 19:28:24 2019 OS/Arch: linux/amd64 Experimental: false
설치를 완료하였으니 본격적으로 도커 사용법에 대해 알아보도록 하겠습니다!
다음 글에서 계속할께요….