SlideShare a Scribd company logo
1 of 49
Download to read offline
. , 2 ,02 1 ,
A 8
서울특별시 강남구 테헤란로83길 32, 5층 (삼성동,
나라키움삼성동A빌딩)
H. www.osci.kr T. 02-516-0711 F. 02-516-0722
. 1 . , 2 ,02 1 , , 10 0
한철희 과장 / 오픈소스컨설팅
Learning Docker
2018.10.15
1. Container
1) Container 란?
2) Docker 란?
3) Docker Engine Installation
2. Docker Engine
1) Docker Architecture
2) Docker Container Operations
3) DockerFile
4) Docker-compose
1. Container
1.1 Container 란?
• 위 사진을 보면 해외 수출, 수입을 위해 많은 컨테이너를 적재한 모습입니다.
• 위키백과에서는 컨테이너를 이렇게 정의 하고 있습니다.
5
1.1 Container 란?
• 컨테이너란, 어플리케이션이 동작하기 위해서 필요한 요소(실행 파일, 어플리케이션 엔진등) 을 패키지화하고 격리 하는
기술을 말합니다.
• 이를 통해 전체 인프라를 쉽고 빠르게 관리 할 수 있게 됩니다.
• 아래 동영상은 컨테이너에 대해 쉽게 설명된 동영상입니다.
6
출처 - Redhat Youtube (https://youtu.be/n-JwAM6XF88)
1.2 Docker 란?
v 도커(Docker)
• 2013년 3월, dotCloud 창업자인 솔로몬 하이크스 가 PyCon Conference 에서 발표
• 기존에 리눅스에 있는 리눅스 컨테이너 기술을 좀 더 활용한 기술
• 애플리케이션을 컨테이너로 좀더 쉽게 사용할 수 있게 만든 오픈소스 프로젝트
• Go 언어로 작성 됨.
• 가상 머신과 비교하여 향상된 성능을 보여줌.
v 도커 프로젝트
• Docker-compose , Docker Machine , Registry 등 다양한 프로젝트 존재
• 일반적으로 Docker 라고 하는 것은
Docker Engine 을 말한다.
• 도커 프로젝트는 Docker Engine 을
효율적으로 사용하기 위한 도구들
7
1.2 Docker 란?
vDocker 가 주목 받는 이유는 무엇일까?
ü가상 머신보다 가벼운 컨테이너
☞ 효율적인 리소스 활용
ü이미지 빌드, 이미지 배포, 이미지 롤백
☞ 서비스의 상태를 관리
ü단순한 빌드, 단순한 배포
8
1.2 Docker 란?
v Containers VS VMs
OVERHEAD
9
1.3 Docker Engine Installation
v Docker 설치
# Test Information
# Test OS Information : CentOS Linux release 7.5.1804 (Core)
# Docker Version : docker-ce-18.06.1.ce-3.el7
v Install Docker Repository
docker-ce Yum Repository를 등록합니다.
# wget https://download.docker.com/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
# yum repolist
v Install docker-ce
docker-ce 를 설치합니다.
# yum -y install docker-ce
# systemctl enable docker;systemctl start docker
10
1.3 Docker Engine Installation
v Docker 서비스 확인
docker 가 정상적으로 설치가 되고 문제없이 사용이 가능한지 확인합니다.
# docker 컨테이너 확인
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
v Docker Daemon 정보 확인
# docker info
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 18.06.1-ce
Storage Driver: overlay2
< ......
중략
...... >
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
11
1.3 Docker Engine Installation
v Docker 기능 테스트
docker 가 정상적으로 설치가 되고 문제없이 사용이 가능한지 확인합니다.
# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9db2ca6ccae0: Pull complete
Digest: sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc
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/engine/userguide/
12
2. Docker Engine
2.1 Docker Architecture
14
2.2 Docker Container Operations
v List Containers
현재 활성화되거나 중지된 컨테이너 목록을 보는 명령어입니다.
컨테이너의 상태 및 가동 시간 등을 보여줍니다.
# docker ps //현재 실행 중인 컨테이너 목록
# docker ps –a //도커 호스트에 있는 컨테이너 모든 목록 확인 ( start, exit, error, dead 등 )
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
032759e31d4c hello-world "/hello" 10 days ago Exited (0) 10 days ago jovial_lovelace
§ CONTAINER ID : 컨테이너 생성시 지정되는 임의의 컨테이너 ID (앞의 12자리만 출력)
§ IMAGE : 컨테이너 생성시 사용된 이미지 이름
§ COMMAND : 컨테이너 시작되면 실행될 명령어
§ CREATED : 컨테이너가 생성된 기간
§ STATUS : 컨테이너 상태 (UP : 실행중, Exited : 중지됨, Pause : 일시중지)
§ PORTS : 컨테이너가 오픈한 포트와 호스트에 연결 상태
§ NAMES : 컨테이너 고유 이름, 중복 불가능, 변경가능
15
2.2 Docker Container Operations
v List Images
로컬 저장소에 pull 받은 Image 목록을 보여줍니다.
# docker images
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 2cb0d9787c4d 2 months ago 1.85kB
16
2.2 Docker Container Operations
v Pull Images
Public Repository 혹은 Private Repository에 있는 container image 를 Local 로 pull 합니다. ( 일종의 다운로드 )
# docker pull [OPTIONS] NAME[:TAG|@DIGEST]
# docker pull httpd //Pull http image
Using default tag: latest
latest: Pulling from library/httpd
f189db1b88b3: Pull complete
ba2d31d4e2e7: Pull complete
23a65f5e3746: Pull complete
5e8eccbd4bc6: Pull complete
4c145eec18d8: Pull complete
1c74ffd6a8a2: Pull complete
1421f0320e1b: Pull complete
Digest: sha256:8631904c6e92918b6c7dd82b72512714e7fbc3f1a1ace2de17cb2746c401b8fb
Status: Downloaded newer image for httpd:latest
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest d595a4011ae3 5 days ago 178MB
han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85kB
hello-world latest 2cb0d9787c4d 2 months ago 1.85kB
17
2.2 Docker Container Operations
v Docker Container Images
Docker Container Image 는 일종의 일반적인 가상화 시스템의 Templates 와 같습니다.
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 2cb0d9787c4d 2 months ago 1.85kB
han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85kB
han0495 / hello-world : latest
Docker Registry 이름 Container Image 이름 Image Version
18
2.2 Docker Container Operations
v Remove Container Images
Local 에 저장된 Container Image 를 삭제합니다.
# docker rmi [OPTIONS] IMAGE [IMAGE...]
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest d595a4011ae3 5 days ago 178MB
hello-world latest 2cb0d9787c4d 2 months ago 1.85kB
han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85kB
# docker rmi hello-world
Untagged: hello-world:latest
Untagged: hello-world@sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest d595a4011ae3 5 days ago 178MB
han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85kB
19
2.2 Docker Container Operations
v Push images
Local 에 있는 container image 를 Public Repository 혹은 Private Repository 로 push 합니다. ( 일종의 업로드 )
# docker push [OPTIONS] NAME[:TAG]
# docker push han0495/hello-world
The push refers to repository [ docker.io/han0495/hello-world ]
ee83fc5847cb: Mounted from library/hello-world
latest: digest: sha256:aca41a608e5eb015f1ec6755f490f3be26b48010b178e78c00eac21ffbe246f1 size: 524
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85kB
hello-world latest 2cb0d9787c4d 2 months ago 1.85kB
위와 같이 docker hub 의 Public Repository 로 push 된 것을 확인 할 수 있습니다.
20
2.2 Docker Container Operations
v Run Containers
Container 를 실행 하는 명령 입니다.
# docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
# docker run httpd
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive
globally to suppress this message
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive
globally to suppress this message
[Mon Sep 10 06:43:19.002515 2018] [mpm_event:notice] [pid 1:tid 140466418673536] AH00489: Apache/2.4.34 (Unix) configured --
resuming normal operations
[Mon Sep 10 06:43:19.002612 2018] [core:notice] [pid 1:tid 140466418673536] AH00094: Command line: 'httpd -D FOREGROUND'
21
2.2 Docker Container Operations
v Remove Containers
현재 실행 중이거나 실행이 종료된 Container 를 제거하는 명령 입니다.
현재 실행 중인 Container 를 강제로 제거 하기 위해서는 -f 옵션을 사용합니다.
# docker rm [OPTIONS] CONTAINER [CONTAINER...]
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c89632a2eede httpd "httpd-foreground" 2 minutes ago Exited (0) 2 minutes ago fervent_wiles
032759e31d4c hello-world "/hello" 10 days ago Exited (0) 10 days ago jovial_lovelace
# docker rm c89632a2eede
c89632a2eede
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
032759e31d4c hello-world "/hello" 10 days ago Exited (0) 10 days ago jovial_lovelace
22
Web 서버를 만들어보자!
2.2 Docker Container Operations
v Docker를 이용해서 Web 서비스 구성
앞서 배운 docker run 명령을 통해 Container 를 시작하고 Web 서비스를 구성 할 수 있습니다.
1) Docker 이미지 Pull 진행
# docker pull httpd
Using default tag: latest
latest: Pulling from library/httpd
Digest: sha256:8631904c6e92918b6c7dd82b72512714e7fbc3f1a1ace2de17cb2746c401b8fb
Status: Image is up to date for httpd:latest
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest d595a4011ae3 5 days ago 178MB
han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85kB
24
2.2 Docker Container Operations
v Docker를 이용해서 Web 서비스 구성
앞서 배운 docker run 명령을 통해 Container 를 시작하고 Web 서비스를 구성 할 수 있습니다.
2) Docker Container 구동
25
Container 가 Foreground 로 작동하면서 Shell 을 사용을 못할 뿐더러, Shell 이 종료가 되면 httpd Container 도 중지가 됩니다.
위와 같이 되면, 전혀 서비스에 적용 할 수가 없습니다.
그리하여 아래와 같이 background 로 container 를 실행하면 됩니다.
2.2 Docker Container Operations
v Docker를 이용해서 Web 서비스 구성
앞서 배운 docker run 명령을 통해 Container 를 시작하고 Web 서비스를 구성 할 수 있습니다.
3) Run Background Docker Container
# docker run -d httpd
3c9764e9b79a058b0dedda07312679d6cafc0779c3e66ae04d9d1034a2b29ee1
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3c9764e9b79a httpd "httpd-foreground" 11 seconds ago Up 10 seconds 80/tcp stupefied_rama
26
위와 같이 Shell 에서 다른 명령도 가능하고 서비스가 계속 실행되는 것을 확인 할 수 있습니다.
그럼 실제로 서비스가 작동하는지 확인해 보겠습니다.
2.2 Docker Container Operations
v Docker를 이용해서 Web 서비스 구성
앞서 배운 docker run 명령을 통해 Container 를 시작하고 Web 서비스를 구성 할 수 있습니다.
4) 서비스 확인
# curl http://127.0.0.1
curl: (7) Failed connect to 127.0.0.1; 연결이 거부됨
27
2.2 Docker Container Operations
v Docker를 이용해서 Web 서비스 구성
§ Docker Network 구조
28
2.2 Docker Container Operations
v Docker를 이용해서 Web 서비스 구성
§ Docker Network 구조
29
2.2 Docker Container Operations
v Docker를 이용해서 Web 서비스 구성
# docker stop 3c9764e9b79a // 기존에 실행중이던 docker container 중지
3c9764e9b79a
# docker ps –a // docker container 중지 확인
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3c9764e9b79a httpd “httpd-foreground” 18 minutes ago Exited (0) 3 seconds ago stupefied_raman
# docker run –d –p 80:80 httpd // add option port mapping
dee5fb60c083564d6095b1b9811b3e634c017caf9788f5fce57a0dcb309e4e76
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dee5fb60c083 httpd "httpd-foreground" 3 seconds ago Up 2 seconds 0.0.0.0:80->80/tcp goofy_sammet
3c9764e9b79a httpd "httpd-foreground" 19 minutes ago Exited (0) 18 seconds ago stupefied_raman
# curl http://127.0.0.1 // 서비스 확인
<html><body><h1>It works!</h1></body></html>
30
2.2 Docker Container Operations
v Docker를 이용해서 Web 서비스 구성
31
2.2 Docker Container Operations
v Docker를 이용해서 Web 서비스 구성
Index.html 수정
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dee5fb60c083 httpd "httpd-foreground" 3 seconds ago Up 2 seconds 0.0.0.0:80->80/tcp goofy_sammet
3c9764e9b79a httpd "httpd-foreground" 19 minutes ago Exited (0) 18 seconds ago stupefied_raman
# docker exec -ti dee5fb60c083 /bin/bash "container 내부로 들어가서 http index.html 을 수정합니다."
root@dee5fb60c083:/usr/local/apache2#
root@dee5fb60c083:/usr/local/apache2# ls
bin build cgi-bin conf error htdocs icons include logs modules
root@dee5fb60c083:/usr/local/apache2# cd htdocs/
root@dee5fb60c083:/usr/local/apache2/htdocs# ls
index.html
root@dee5fb60c083:/usr/local/apache2/htdocs# cat index.html
<html><body><h1>It works!</h1></body></html>
root@dee5fb60c083:/usr/local/apache2/htdocs# echo "<html><body><h1>Docker Test Page</h1></body></html>" > index.html
root@dee5fb60c083:/usr/local/apache2/htdocs# cat index.html
<html><body><h1>Docker Test Page</h1></body></html>
root@dee5fb60c083:/usr/local/apache2/htdocs# exit
Exit
# curl http://192.168.13.131
<html><body><h1>Docker Test Page</h1></body></html>
32
2.2 Docker Container Operations
v Docker를 이용해서 Web 서비스 구성
33
2.3 DockerFile
v DockerFile 이란?
DockerFile 이란, 나만의 Container image를 Build 할 수 있게 해주는 Docker image 파일 입니다.
Docker Hub 에 없는 이미지도 DockerFile 을 이용하면 특별한 image 도 생성 할 수 있습니다.
DockerFile
# cat dockerfile
FROM httpd:latest
MAINTAINER chhan <chhan@osci.kr>
RUN echo "<html><body><h1>Docker File Test Page</h1></body></html>" > /usr/local/apache2/htdocs/index.html
EXPOSE 80
34
2.3 DockerFile
v DockerFile
35
# cat dockerfile
FROM httpd:latest
MAINTAINER chhan <chhan@osci.kr>
RUN echo "<html><body><h1>Docker File Test Page</h1></body></html>" > /usr/local/apache2/htdocs/index.html
EXPOSE 80
• FROM
Docker Hub 에서 어떤 이미지를 가지고 와서 작업할지 선언합니다. 작성법은 <이미지명>:<태그> 로 작성합니다.
• MAINTAINER
DockerFile 제작한 사람의 정보를 기입합니다.
• RUN
docker image 가 실행되고 container 내에서 실행될 명령어입니다.
해당 내용은 적으면 적을수록 container label 이 적게 생성되어 image 를 compact 하게 생성 할 수 있습니다.
• EXPOSE
Host 에 연결될 Port를 지정합니다.
위와 같은 DockerFile 구문을 자세히 확인하려면 아래 문서를 참고하시면 됩니다.
( https://docs.docker.com/engine/reference/builder/ )
2.3 DockerFile
v DockerFile Build
36
# pwd
/root/http
# ls
dockerfile
# docker build -t myhttpd .
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM httpd:latest
---> d595a4011ae3
Step 2/4 : MAINTAINER chhan <chhan@osci.kr>
---> Running in 176d94e63272
Removing intermediate container 176d94e63272
---> 282d30eba8fe
Step 3/4 : RUN echo "<html><body><h1>Docker File Test Page</h1></body></html>" > /usr/local/apache2/htdocs/index.html
---> Running in 2f16f1ef9d1c
Removing intermediate container 2f16f1ef9d1c
---> df135d6e6dbd
Step 4/4 : EXPOSE 80
---> Running in 12cdc41b8546
Removing intermediate container 12cdc41b8546
---> 52c07f2bfb38
Successfully built 52c07f2bfb38
Successfully tagged myhttpd:latest
2.3 DockerFile
v DockerFile Build
37
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myhttpd latest 52c07f2bfb38 3 seconds ago 178MB
httpd latest d595a4011ae3 5 days ago 178MB
han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85kB
# docker run -d -p 80:80 --name=myweb myhttpd
1afd260265923828f88eeae9bc7083985b66eef2d9c588d35ee08e05198470a0
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1afd26026592 myhttpd "httpd-foreground" 5 seconds ago Up 5 seconds 0.0.0.0:80->80/tcp myweb
# curl http://192.168.13.131
<html><body><h1>Docker File Test Page</h1></body></html>
이처럼 DockerFile 을 통해 작성한 container image 를 통해 매번 index File 이 수정된 Web 서비스를 실행 할 수 있습니다.
Blog 를 만들어 보자!
2.4 Docker-compose
v docker-compose 로 Container 통합 관리
docker-compose 란, 한번에 여러 container 을 통합 관리 할 수 있게 하는 툴입니다.
v docker-compose 설치
39
# curl -L "https://github.com/docker/compose/releases/download/1.22.0/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
100 617 0 617 0 0 558 0 --:--:-- 0:00:01 --:--:-- 559
100 11.2M 100 11.2M 0 0 2186k 0 0:00:05 0:00:05 --:--:-- 3668k
# chmod +x /usr/local/bin/docker-compose
# ls -l /usr/local/bin/docker-compose
-rwxr-xr-x 1 root root 11750136 9월 10 17:26 /usr/local/bin/docker-compose
# docker-compose --version
docker-compose version 1.22.0, build f46880fe
2.4 Docker-compose
v docker-compose 로 Container 통합 관리
docker-compose.yml 작성
40
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- /var/lib/mysql:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: passwordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "80:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
2.4 Docker-compose
v docker-compose 로 Container 통합 관리
docker-compose.yml 을 실행
(-f [File] , -d background 실행)
41
# docker-compose -f docker-compose.yml up -d
2.4 Docker-compose
v docker-compose 로 Container 통합 관리
docker-compose.yml 을 실행
42
# ls -la /root/wordpress/docker-compose.yml
-rw-r--r-- 1 root root 537 9월 10 17:35 /root/wordpress/docker-compose.yml
# docker-compose -f docker-compose.yml up -d
Creating network "wordpress_default" with the default driver
Pulling db (mysql:5.7)...
5.7: Pulling from library/mysql
802b00ed6f79: Pull complete
30f19a05b898: Pull complete
3e43303be5e9: Pull complete
94b281824ae2: Pull complete
51eb397095b1: Pull complete
54567da6fdf0: Pull complete
bc57ddb85cce: Pull complete
c7c0a9c25d8a: Pull complete
cce6c47ac3fc: Pull complete
499b9c7376c8: Pull complete
6c5e08e005ea: Pull complete
Digest: sha256:1d8f471c7e2929ee1e2bfbc1d16fc8afccd2e070afed24805487e726ce601a6d
Status: Downloaded newer image for mysql:5.7
2.4 Docker-compose
v docker-compose 로 Container 통합 관리
docker-compose.yml 을 실행
43
Pulling wordpress (wordpress:latest)...
latest: Pulling from library/wordpress
802b00ed6f79: Already exists
59f5a5a895f8: Pull complete
6898b2dbcfeb: Pull complete
8e0903aaa47e: Pull complete
2961af1e196a: Pull complete
71f7016f79a0: Pull complete
5e1a48e5719c: Pull complete
7ae5291984f3: Pull complete
725b65166f31: Pull complete
3823a607a5d4: Pull complete
1bcfa4198e39: Pull complete
f1c79da21110: Pull complete
18903f439956: Pull complete
5eda25fffde3: Pull complete
3800dac98824: Pull complete
951fbb644962: Pull complete
5b91123e33c5: Pull complete
71250bb070e7: Pull complete
0363e75875b5: Pull complete
3bcb3cbf244a: Pull complete
Digest: sha256:e30aed2d17b33758544f0eaebee763a452b41ff5bc926d723566338b0137dd81
Status: Downloaded newer image for wordpress:latest
Creating wordpress_db_1 ... done
Creating wordpress_wordpress_1 ... done
2.4 Docker-compose
v docker-compose 로 Container 통합 관리
# docker-compose ps // docker-compose로 작동 중인 Container 현황
# docker-compose top // docker-compose 가 관리중인 Container Process 정보
44
# docker-compose ps
Name Command State Ports
-------------------------------------------------------------------------------------
wordpress_db_1 docker-entrypoint.sh mysqld Up 3306/tcp, 33060/tcp
wordpress_wordpress_1 docker-entrypoint.sh apach ... Up 0.0.0.0:8000->80/tcp
# docker-compose top
wordpress_db_1
UID PID PPID C STIME TTY TIME CMD
-------------------------------------------------------------
polkitd 10737 10716 0 17:41 ? 00:00:00 mysqld
wordpress_wordpress_1
UID PID PPID C STIME TTY TIME CMD
------------------------------------------------------------------------
root 10997 10977 0 17:41 ? 00:00:00 apache2 -DFOREGROUND
33 14530 10997 0 17:41 ? 00:00:00 apache2 -DFOREGROUND
33 14531 10997 0 17:41 ? 00:00:00 apache2 -DFOREGROUND
33 14533 10997 0 17:41 ? 00:00:00 apache2 -DFOREGROUND
33 14534 10997 0 17:41 ? 00:00:00 apache2 -DFOREGROUND
33 14535 10997 0 17:41 ? 00:00:00 apache2 -DFOREGROUND
2.4 Docker-compose
v docker-compose 로 Container 통합 관리
45
2.4 Docker-compose
v docker-compose 로 Container 통합 관리
46
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
25c5e75bb07d wordpress:latest "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 0.0.0.0:8000->80/tcp
wordpress_wordpress_1
f52a5d2495e4 mysql:5.7 "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 3306/tcp, 33060/tcp wordpress_db_1
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myhttpd latest 52c07f2bfb38 About an hour ago 178MB
wordpress latest 63b422244491 2 days ago 409MB
mysql 5.7 563a026a1511 5 days ago 372MB
httpd latest d595a4011ae3 5 days ago 178MB
han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85k
• Local 에 없던 image를 자동으로 Download 했습니다.
• docker container 를 실행했습니다.
• /var/lib/mysql 를 영구적 볼륨으로 할당하였습니다.
• docker 내부 포트를 외부 포트와 Mapping 하였습니다.
• container 를 순서대로 실행했습니다
3. 참고 자료
3. 참고 자료
v 참고 자료
• Cgroup : https://access.redhat.com/documentation/ko-
kr/red_hat_enterprise_linux/6/html/resource_management_guide/ch01
• namespace : https://access.redhat.com/documentation/en-
us/red_hat_enterprise_linux_atomic_host/7/html/overview_of_containers_in_red_hat_systems/introduction_to_l
inux_containers
• docker : https://docs.docker.com/
• Sideshare
• Google Image Search
• docker lab : https://training.play-with-docker.com/
48
Thank you.

More Related Content

What's hot

Introduction to Docker - VIT Campus
Introduction to Docker - VIT CampusIntroduction to Docker - VIT Campus
Introduction to Docker - VIT CampusAjeet Singh Raina
 
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...Edureka!
 
Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker, Inc.
 
Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with DockerRavindu Fernando
 
Docker introduction
Docker introductionDocker introduction
Docker introductiondotCloud
 
Docker introduction for the beginners
Docker introduction for the beginnersDocker introduction for the beginners
Docker introduction for the beginnersJuneyoung Oh
 
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...Edureka!
 
Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기raccoony
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)Gourav Varma
 
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day ThailandCI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day ThailandTroublemaker Khunpech
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker IntroductionPeng Xiao
 
Docker introduction &amp; benefits
Docker introduction &amp; benefitsDocker introduction &amp; benefits
Docker introduction &amp; benefitsAmit Manwade
 
Container orchestration overview
Container orchestration overviewContainer orchestration overview
Container orchestration overviewWyn B. Van Devanter
 
Docker multi-stage build
Docker multi-stage buildDocker multi-stage build
Docker multi-stage buildAlexei Ledenev
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageejlp12
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to DockerAditya Konarde
 

What's hot (20)

What is Docker
What is DockerWhat is Docker
What is Docker
 
Introduction to Docker - VIT Campus
Introduction to Docker - VIT CampusIntroduction to Docker - VIT Campus
Introduction to Docker - VIT Campus
 
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
 
Docker 101 - Nov 2016
Docker 101 - Nov 2016Docker 101 - Nov 2016
Docker 101 - Nov 2016
 
Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with Docker
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Docker introduction for the beginners
Docker introduction for the beginnersDocker introduction for the beginners
Docker introduction for the beginners
 
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
Docker Commands With Examples | Docker Tutorial | DevOps Tutorial | Docker Tr...
 
Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)
 
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day ThailandCI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Docker introduction &amp; benefits
Docker introduction &amp; benefitsDocker introduction &amp; benefits
Docker introduction &amp; benefits
 
Docker
DockerDocker
Docker
 
Container orchestration overview
Container orchestration overviewContainer orchestration overview
Container orchestration overview
 
Docker swarm
Docker swarmDocker swarm
Docker swarm
 
Docker multi-stage build
Docker multi-stage buildDocker multi-stage build
Docker multi-stage build
 
Multi Stage Docker Build
Multi Stage Docker Build Multi Stage Docker Build
Multi Stage Docker Build
 
Introduction to Docker storage, volume and image
Introduction to Docker storage, volume and imageIntroduction to Docker storage, volume and image
Introduction to Docker storage, volume and image
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 

Similar to [오픈소스컨설팅]Docker기초 실습 교육 20181113_v3

Introduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOTIntroduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOTHosang Jeon
 
Introduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOTIntroduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOTLOGISPOT
 
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 DockerXECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 DockerXpressEngine
 
[오픈소스컨설팅]Docker on Kubernetes v1
[오픈소스컨설팅]Docker on Kubernetes v1[오픈소스컨설팅]Docker on Kubernetes v1
[오픈소스컨설팅]Docker on Kubernetes v1Ji-Woong Choi
 
[오픈소스컨설팅]Docker on Cloud(Digital Ocean)
[오픈소스컨설팅]Docker on Cloud(Digital Ocean)[오픈소스컨설팅]Docker on Cloud(Digital Ocean)
[오픈소스컨설팅]Docker on Cloud(Digital Ocean)Ji-Woong Choi
 
docker_quick_start
docker_quick_startdocker_quick_start
docker_quick_startSukjin Yun
 
Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]
Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]
Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]David Lee
 
도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day
도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day
도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container DayAmazon Web Services Korea
 
docker on GCE ( JIRA & Confluence ) - GDG Korea Cloud
docker on GCE ( JIRA & Confluence ) - GDG Korea Clouddocker on GCE ( JIRA & Confluence ) - GDG Korea Cloud
docker on GCE ( JIRA & Confluence ) - GDG Korea CloudJude Kim
 
aws/docker/rails를 활용한 시스템 구축/운용 - docker편
aws/docker/rails를 활용한 시스템 구축/운용 - docker편aws/docker/rails를 활용한 시스템 구축/운용 - docker편
aws/docker/rails를 활용한 시스템 구축/운용 - docker편negabaro
 
[1A6]Docker로 보는 서버 운영의 미래
[1A6]Docker로 보는 서버 운영의 미래[1A6]Docker로 보는 서버 운영의 미래
[1A6]Docker로 보는 서버 운영의 미래NAVER D2
 
[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)
[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)
[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)CONNECT FOUNDATION
 
Docker 사용가이드 public v0.1
Docker 사용가이드 public v0.1Docker 사용가이드 public v0.1
Docker 사용가이드 public v0.1Steve Shim
 
하이퍼레저 패브릭 실습자료
하이퍼레저 패브릭 실습자료하이퍼레저 패브릭 실습자료
하이퍼레저 패브릭 실습자료TIMEGATE
 
Confd, systemd, fleet을 이용한 어플리케이션 배포 in CoreOS
Confd, systemd, fleet을 이용한 어플리케이션 배포 in CoreOSConfd, systemd, fleet을 이용한 어플리케이션 배포 in CoreOS
Confd, systemd, fleet을 이용한 어플리케이션 배포 in CoreOS충섭 김
 
[오픈소스컨설팅] Docker를 활용한 Gitlab CI/CD 구성 테스트
[오픈소스컨설팅] Docker를 활용한 Gitlab CI/CD 구성 테스트[오픈소스컨설팅] Docker를 활용한 Gitlab CI/CD 구성 테스트
[오픈소스컨설팅] Docker를 활용한 Gitlab CI/CD 구성 테스트Ji-Woong Choi
 
postgres_빌드_및_디버깅.pdf
postgres_빌드_및_디버깅.pdfpostgres_빌드_및_디버깅.pdf
postgres_빌드_및_디버깅.pdfLee Dong Wook
 
Docker 로 Linux 없이 Linux 환경에서 개발하기
Docker 로 Linux 없이 Linux 환경에서 개발하기Docker 로 Linux 없이 Linux 환경에서 개발하기
Docker 로 Linux 없이 Linux 환경에서 개발하기iFunFactory Inc.
 

Similar to [오픈소스컨설팅]Docker기초 실습 교육 20181113_v3 (20)

Introduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOTIntroduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOT
 
Introduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOTIntroduction to Docker - LOGISPOT
Introduction to Docker - LOGISPOT
 
Docker osc 0508
Docker osc 0508Docker osc 0508
Docker osc 0508
 
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 DockerXECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
XECon2015 :: [1-5] 김훈민 - 서버 운영자가 꼭 알아야 할 Docker
 
[오픈소스컨설팅]Docker on Kubernetes v1
[오픈소스컨설팅]Docker on Kubernetes v1[오픈소스컨설팅]Docker on Kubernetes v1
[오픈소스컨설팅]Docker on Kubernetes v1
 
[오픈소스컨설팅]Docker on Cloud(Digital Ocean)
[오픈소스컨설팅]Docker on Cloud(Digital Ocean)[오픈소스컨설팅]Docker on Cloud(Digital Ocean)
[오픈소스컨설팅]Docker on Cloud(Digital Ocean)
 
docker_quick_start
docker_quick_startdocker_quick_start
docker_quick_start
 
Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]
Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]
Docker 기본 및 Docker Swarm을 활용한 분산 서버 관리 A부터 Z까지 [전체모드에서 봐주세요]
 
K8s in action02
K8s in action02K8s in action02
K8s in action02
 
도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day
도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day
도커의 기초 - 김상필 솔루션즈 아키텍트 :: AWS Container Day
 
docker on GCE ( JIRA & Confluence ) - GDG Korea Cloud
docker on GCE ( JIRA & Confluence ) - GDG Korea Clouddocker on GCE ( JIRA & Confluence ) - GDG Korea Cloud
docker on GCE ( JIRA & Confluence ) - GDG Korea Cloud
 
aws/docker/rails를 활용한 시스템 구축/운용 - docker편
aws/docker/rails를 활용한 시스템 구축/운용 - docker편aws/docker/rails를 활용한 시스템 구축/운용 - docker편
aws/docker/rails를 활용한 시스템 구축/운용 - docker편
 
[1A6]Docker로 보는 서버 운영의 미래
[1A6]Docker로 보는 서버 운영의 미래[1A6]Docker로 보는 서버 운영의 미래
[1A6]Docker로 보는 서버 운영의 미래
 
[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)
[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)
[부스트캠퍼세미나]육진혁_(대충 도커 쓰자는 이야기)
 
Docker 사용가이드 public v0.1
Docker 사용가이드 public v0.1Docker 사용가이드 public v0.1
Docker 사용가이드 public v0.1
 
하이퍼레저 패브릭 실습자료
하이퍼레저 패브릭 실습자료하이퍼레저 패브릭 실습자료
하이퍼레저 패브릭 실습자료
 
Confd, systemd, fleet을 이용한 어플리케이션 배포 in CoreOS
Confd, systemd, fleet을 이용한 어플리케이션 배포 in CoreOSConfd, systemd, fleet을 이용한 어플리케이션 배포 in CoreOS
Confd, systemd, fleet을 이용한 어플리케이션 배포 in CoreOS
 
[오픈소스컨설팅] Docker를 활용한 Gitlab CI/CD 구성 테스트
[오픈소스컨설팅] Docker를 활용한 Gitlab CI/CD 구성 테스트[오픈소스컨설팅] Docker를 활용한 Gitlab CI/CD 구성 테스트
[오픈소스컨설팅] Docker를 활용한 Gitlab CI/CD 구성 테스트
 
postgres_빌드_및_디버깅.pdf
postgres_빌드_및_디버깅.pdfpostgres_빌드_및_디버깅.pdf
postgres_빌드_및_디버깅.pdf
 
Docker 로 Linux 없이 Linux 환경에서 개발하기
Docker 로 Linux 없이 Linux 환경에서 개발하기Docker 로 Linux 없이 Linux 환경에서 개발하기
Docker 로 Linux 없이 Linux 환경에서 개발하기
 

More from Ji-Woong Choi

[오픈소스컨설팅] 오픈소스 기반 솔루션 방향성 잡기
[오픈소스컨설팅] 오픈소스 기반 솔루션 방향성 잡기[오픈소스컨설팅] 오픈소스 기반 솔루션 방향성 잡기
[오픈소스컨설팅] 오픈소스 기반 솔루션 방향성 잡기Ji-Woong Choi
 
[오픈소스컨설팅] 스카우터 사용자 가이드 2020
[오픈소스컨설팅] 스카우터 사용자 가이드 2020[오픈소스컨설팅] 스카우터 사용자 가이드 2020
[오픈소스컨설팅] 스카우터 사용자 가이드 2020Ji-Woong Choi
 
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축Ji-Woong Choi
 
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기Ji-Woong Choi
 
[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육
[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육
[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육Ji-Woong Choi
 
[오픈소스컨설팅] 2019년 클라우드 생존전략
[오픈소스컨설팅] 2019년 클라우드 생존전략[오픈소스컨설팅] 2019년 클라우드 생존전략
[오픈소스컨설팅] 2019년 클라우드 생존전략Ji-Woong Choi
 
[오픈소스컨설팅] AWS re:Invent 2018 기계학습(ML)부분 후기
[오픈소스컨설팅] AWS re:Invent 2018 기계학습(ML)부분 후기[오픈소스컨설팅] AWS re:Invent 2018 기계학습(ML)부분 후기
[오픈소스컨설팅] AWS re:Invent 2018 기계학습(ML)부분 후기Ji-Woong Choi
 
[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3
[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3
[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3Ji-Woong Choi
 
[오픈소스컨설팅]ELK기반 장애예방시스템_구성_2016.12
[오픈소스컨설팅]ELK기반 장애예방시스템_구성_2016.12[오픈소스컨설팅]ELK기반 장애예방시스템_구성_2016.12
[오픈소스컨설팅]ELK기반 장애예방시스템_구성_2016.12Ji-Woong Choi
 
[오픈소스컨설팅]클라우드기반U2L마이그레이션 전략 및 고려사항
[오픈소스컨설팅]클라우드기반U2L마이그레이션 전략 및 고려사항[오픈소스컨설팅]클라우드기반U2L마이그레이션 전략 및 고려사항
[오픈소스컨설팅]클라우드기반U2L마이그레이션 전략 및 고려사항Ji-Woong Choi
 
OpenStack Summit 2017 참석후기
OpenStack Summit 2017 참석후기OpenStack Summit 2017 참석후기
OpenStack Summit 2017 참석후기Ji-Woong Choi
 
[오픈소스컨설팅] Red Hat ReaR (relax and-recover) Quick Guide
[오픈소스컨설팅] Red Hat ReaR (relax and-recover) Quick Guide[오픈소스컨설팅] Red Hat ReaR (relax and-recover) Quick Guide
[오픈소스컨설팅] Red Hat ReaR (relax and-recover) Quick GuideJi-Woong Choi
 
[오픈소스컨설팅] Open Stack Ceph, Neutron, HA, Multi-Region
[오픈소스컨설팅] Open Stack Ceph, Neutron, HA, Multi-Region[오픈소스컨설팅] Open Stack Ceph, Neutron, HA, Multi-Region
[오픈소스컨설팅] Open Stack Ceph, Neutron, HA, Multi-RegionJi-Woong Choi
 
Docker Setting for Static IP allocation
Docker Setting for Static IP allocationDocker Setting for Static IP allocation
Docker Setting for Static IP allocationJi-Woong Choi
 
Scouter와 influx db – grafana 연동 가이드
Scouter와 influx db – grafana 연동 가이드Scouter와 influx db – grafana 연동 가이드
Scouter와 influx db – grafana 연동 가이드Ji-Woong Choi
 
[오픈소스컨설팅]Atlassian JIRA Quick Guide
[오픈소스컨설팅]Atlassian JIRA Quick Guide[오픈소스컨설팅]Atlassian JIRA Quick Guide
[오픈소스컨설팅]Atlassian JIRA Quick GuideJi-Woong Choi
 
[오픈소스컨설팅]레드햇계열리눅스7 운영자가이드 - 기초편
[오픈소스컨설팅]레드햇계열리눅스7 운영자가이드 - 기초편[오픈소스컨설팅]레드햇계열리눅스7 운영자가이드 - 기초편
[오픈소스컨설팅]레드햇계열리눅스7 운영자가이드 - 기초편Ji-Woong Choi
 
[오픈소스컨설팅]systemd on RHEL7
[오픈소스컨설팅]systemd on RHEL7[오픈소스컨설팅]systemd on RHEL7
[오픈소스컨설팅]systemd on RHEL7Ji-Woong Choi
 
클라우드 컴퓨팅 기반 기술과 오픈스택(Kvm) 기반 Provisioning
클라우드 컴퓨팅 기반 기술과 오픈스택(Kvm) 기반 Provisioning 클라우드 컴퓨팅 기반 기술과 오픈스택(Kvm) 기반 Provisioning
클라우드 컴퓨팅 기반 기술과 오픈스택(Kvm) 기반 Provisioning Ji-Woong Choi
 
[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)
[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)
[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)Ji-Woong Choi
 

More from Ji-Woong Choi (20)

[오픈소스컨설팅] 오픈소스 기반 솔루션 방향성 잡기
[오픈소스컨설팅] 오픈소스 기반 솔루션 방향성 잡기[오픈소스컨설팅] 오픈소스 기반 솔루션 방향성 잡기
[오픈소스컨설팅] 오픈소스 기반 솔루션 방향성 잡기
 
[오픈소스컨설팅] 스카우터 사용자 가이드 2020
[오픈소스컨설팅] 스카우터 사용자 가이드 2020[오픈소스컨설팅] 스카우터 사용자 가이드 2020
[오픈소스컨설팅] 스카우터 사용자 가이드 2020
 
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
 
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
[오픈소스컨설팅] 프로메테우스 모니터링 살펴보고 구성하기
 
[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육
[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육
[오픈소스컨설팅] Ansible을 활용한 운영 자동화 교육
 
[오픈소스컨설팅] 2019년 클라우드 생존전략
[오픈소스컨설팅] 2019년 클라우드 생존전략[오픈소스컨설팅] 2019년 클라우드 생존전략
[오픈소스컨설팅] 2019년 클라우드 생존전략
 
[오픈소스컨설팅] AWS re:Invent 2018 기계학습(ML)부분 후기
[오픈소스컨설팅] AWS re:Invent 2018 기계학습(ML)부분 후기[오픈소스컨설팅] AWS re:Invent 2018 기계학습(ML)부분 후기
[오픈소스컨설팅] AWS re:Invent 2018 기계학습(ML)부분 후기
 
[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3
[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3
[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3
 
[오픈소스컨설팅]ELK기반 장애예방시스템_구성_2016.12
[오픈소스컨설팅]ELK기반 장애예방시스템_구성_2016.12[오픈소스컨설팅]ELK기반 장애예방시스템_구성_2016.12
[오픈소스컨설팅]ELK기반 장애예방시스템_구성_2016.12
 
[오픈소스컨설팅]클라우드기반U2L마이그레이션 전략 및 고려사항
[오픈소스컨설팅]클라우드기반U2L마이그레이션 전략 및 고려사항[오픈소스컨설팅]클라우드기반U2L마이그레이션 전략 및 고려사항
[오픈소스컨설팅]클라우드기반U2L마이그레이션 전략 및 고려사항
 
OpenStack Summit 2017 참석후기
OpenStack Summit 2017 참석후기OpenStack Summit 2017 참석후기
OpenStack Summit 2017 참석후기
 
[오픈소스컨설팅] Red Hat ReaR (relax and-recover) Quick Guide
[오픈소스컨설팅] Red Hat ReaR (relax and-recover) Quick Guide[오픈소스컨설팅] Red Hat ReaR (relax and-recover) Quick Guide
[오픈소스컨설팅] Red Hat ReaR (relax and-recover) Quick Guide
 
[오픈소스컨설팅] Open Stack Ceph, Neutron, HA, Multi-Region
[오픈소스컨설팅] Open Stack Ceph, Neutron, HA, Multi-Region[오픈소스컨설팅] Open Stack Ceph, Neutron, HA, Multi-Region
[오픈소스컨설팅] Open Stack Ceph, Neutron, HA, Multi-Region
 
Docker Setting for Static IP allocation
Docker Setting for Static IP allocationDocker Setting for Static IP allocation
Docker Setting for Static IP allocation
 
Scouter와 influx db – grafana 연동 가이드
Scouter와 influx db – grafana 연동 가이드Scouter와 influx db – grafana 연동 가이드
Scouter와 influx db – grafana 연동 가이드
 
[오픈소스컨설팅]Atlassian JIRA Quick Guide
[오픈소스컨설팅]Atlassian JIRA Quick Guide[오픈소스컨설팅]Atlassian JIRA Quick Guide
[오픈소스컨설팅]Atlassian JIRA Quick Guide
 
[오픈소스컨설팅]레드햇계열리눅스7 운영자가이드 - 기초편
[오픈소스컨설팅]레드햇계열리눅스7 운영자가이드 - 기초편[오픈소스컨설팅]레드햇계열리눅스7 운영자가이드 - 기초편
[오픈소스컨설팅]레드햇계열리눅스7 운영자가이드 - 기초편
 
[오픈소스컨설팅]systemd on RHEL7
[오픈소스컨설팅]systemd on RHEL7[오픈소스컨설팅]systemd on RHEL7
[오픈소스컨설팅]systemd on RHEL7
 
클라우드 컴퓨팅 기반 기술과 오픈스택(Kvm) 기반 Provisioning
클라우드 컴퓨팅 기반 기술과 오픈스택(Kvm) 기반 Provisioning 클라우드 컴퓨팅 기반 기술과 오픈스택(Kvm) 기반 Provisioning
클라우드 컴퓨팅 기반 기술과 오픈스택(Kvm) 기반 Provisioning
 
[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)
[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)
[오픈소스컨설팅]Scouter 설치 및 사용가이드(JBoss)
 

[오픈소스컨설팅]Docker기초 실습 교육 20181113_v3

  • 1. . , 2 ,02 1 , A 8 서울특별시 강남구 테헤란로83길 32, 5층 (삼성동, 나라키움삼성동A빌딩) H. www.osci.kr T. 02-516-0711 F. 02-516-0722 . 1 . , 2 ,02 1 , , 10 0
  • 2. 한철희 과장 / 오픈소스컨설팅 Learning Docker 2018.10.15
  • 3. 1. Container 1) Container 란? 2) Docker 란? 3) Docker Engine Installation 2. Docker Engine 1) Docker Architecture 2) Docker Container Operations 3) DockerFile 4) Docker-compose
  • 5. 1.1 Container 란? • 위 사진을 보면 해외 수출, 수입을 위해 많은 컨테이너를 적재한 모습입니다. • 위키백과에서는 컨테이너를 이렇게 정의 하고 있습니다. 5
  • 6. 1.1 Container 란? • 컨테이너란, 어플리케이션이 동작하기 위해서 필요한 요소(실행 파일, 어플리케이션 엔진등) 을 패키지화하고 격리 하는 기술을 말합니다. • 이를 통해 전체 인프라를 쉽고 빠르게 관리 할 수 있게 됩니다. • 아래 동영상은 컨테이너에 대해 쉽게 설명된 동영상입니다. 6 출처 - Redhat Youtube (https://youtu.be/n-JwAM6XF88)
  • 7. 1.2 Docker 란? v 도커(Docker) • 2013년 3월, dotCloud 창업자인 솔로몬 하이크스 가 PyCon Conference 에서 발표 • 기존에 리눅스에 있는 리눅스 컨테이너 기술을 좀 더 활용한 기술 • 애플리케이션을 컨테이너로 좀더 쉽게 사용할 수 있게 만든 오픈소스 프로젝트 • Go 언어로 작성 됨. • 가상 머신과 비교하여 향상된 성능을 보여줌. v 도커 프로젝트 • Docker-compose , Docker Machine , Registry 등 다양한 프로젝트 존재 • 일반적으로 Docker 라고 하는 것은 Docker Engine 을 말한다. • 도커 프로젝트는 Docker Engine 을 효율적으로 사용하기 위한 도구들 7
  • 8. 1.2 Docker 란? vDocker 가 주목 받는 이유는 무엇일까? ü가상 머신보다 가벼운 컨테이너 ☞ 효율적인 리소스 활용 ü이미지 빌드, 이미지 배포, 이미지 롤백 ☞ 서비스의 상태를 관리 ü단순한 빌드, 단순한 배포 8
  • 9. 1.2 Docker 란? v Containers VS VMs OVERHEAD 9
  • 10. 1.3 Docker Engine Installation v Docker 설치 # Test Information # Test OS Information : CentOS Linux release 7.5.1804 (Core) # Docker Version : docker-ce-18.06.1.ce-3.el7 v Install Docker Repository docker-ce Yum Repository를 등록합니다. # wget https://download.docker.com/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo # yum repolist v Install docker-ce docker-ce 를 설치합니다. # yum -y install docker-ce # systemctl enable docker;systemctl start docker 10
  • 11. 1.3 Docker Engine Installation v Docker 서비스 확인 docker 가 정상적으로 설치가 되고 문제없이 사용이 가능한지 확인합니다. # docker 컨테이너 확인 # docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES v Docker Daemon 정보 확인 # docker info Containers: 1 Running: 0 Paused: 0 Stopped: 1 Images: 1 Server Version: 18.06.1-ce Storage Driver: overlay2 < ...... 중략 ...... > Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false 11
  • 12. 1.3 Docker Engine Installation v Docker 기능 테스트 docker 가 정상적으로 설치가 되고 문제없이 사용이 가능한지 확인합니다. # docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 9db2ca6ccae0: Pull complete Digest: sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc 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/engine/userguide/ 12
  • 15. 2.2 Docker Container Operations v List Containers 현재 활성화되거나 중지된 컨테이너 목록을 보는 명령어입니다. 컨테이너의 상태 및 가동 시간 등을 보여줍니다. # docker ps //현재 실행 중인 컨테이너 목록 # docker ps –a //도커 호스트에 있는 컨테이너 모든 목록 확인 ( start, exit, error, dead 등 ) # docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 032759e31d4c hello-world "/hello" 10 days ago Exited (0) 10 days ago jovial_lovelace § CONTAINER ID : 컨테이너 생성시 지정되는 임의의 컨테이너 ID (앞의 12자리만 출력) § IMAGE : 컨테이너 생성시 사용된 이미지 이름 § COMMAND : 컨테이너 시작되면 실행될 명령어 § CREATED : 컨테이너가 생성된 기간 § STATUS : 컨테이너 상태 (UP : 실행중, Exited : 중지됨, Pause : 일시중지) § PORTS : 컨테이너가 오픈한 포트와 호스트에 연결 상태 § NAMES : 컨테이너 고유 이름, 중복 불가능, 변경가능 15
  • 16. 2.2 Docker Container Operations v List Images 로컬 저장소에 pull 받은 Image 목록을 보여줍니다. # docker images # docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest 2cb0d9787c4d 2 months ago 1.85kB 16
  • 17. 2.2 Docker Container Operations v Pull Images Public Repository 혹은 Private Repository에 있는 container image 를 Local 로 pull 합니다. ( 일종의 다운로드 ) # docker pull [OPTIONS] NAME[:TAG|@DIGEST] # docker pull httpd //Pull http image Using default tag: latest latest: Pulling from library/httpd f189db1b88b3: Pull complete ba2d31d4e2e7: Pull complete 23a65f5e3746: Pull complete 5e8eccbd4bc6: Pull complete 4c145eec18d8: Pull complete 1c74ffd6a8a2: Pull complete 1421f0320e1b: Pull complete Digest: sha256:8631904c6e92918b6c7dd82b72512714e7fbc3f1a1ace2de17cb2746c401b8fb Status: Downloaded newer image for httpd:latest # docker images REPOSITORY TAG IMAGE ID CREATED SIZE httpd latest d595a4011ae3 5 days ago 178MB han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85kB hello-world latest 2cb0d9787c4d 2 months ago 1.85kB 17
  • 18. 2.2 Docker Container Operations v Docker Container Images Docker Container Image 는 일종의 일반적인 가상화 시스템의 Templates 와 같습니다. # docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest 2cb0d9787c4d 2 months ago 1.85kB han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85kB han0495 / hello-world : latest Docker Registry 이름 Container Image 이름 Image Version 18
  • 19. 2.2 Docker Container Operations v Remove Container Images Local 에 저장된 Container Image 를 삭제합니다. # docker rmi [OPTIONS] IMAGE [IMAGE...] # docker images REPOSITORY TAG IMAGE ID CREATED SIZE httpd latest d595a4011ae3 5 days ago 178MB hello-world latest 2cb0d9787c4d 2 months ago 1.85kB han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85kB # docker rmi hello-world Untagged: hello-world:latest Untagged: hello-world@sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc # docker images REPOSITORY TAG IMAGE ID CREATED SIZE httpd latest d595a4011ae3 5 days ago 178MB han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85kB 19
  • 20. 2.2 Docker Container Operations v Push images Local 에 있는 container image 를 Public Repository 혹은 Private Repository 로 push 합니다. ( 일종의 업로드 ) # docker push [OPTIONS] NAME[:TAG] # docker push han0495/hello-world The push refers to repository [ docker.io/han0495/hello-world ] ee83fc5847cb: Mounted from library/hello-world latest: digest: sha256:aca41a608e5eb015f1ec6755f490f3be26b48010b178e78c00eac21ffbe246f1 size: 524 # docker images REPOSITORY TAG IMAGE ID CREATED SIZE han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85kB hello-world latest 2cb0d9787c4d 2 months ago 1.85kB 위와 같이 docker hub 의 Public Repository 로 push 된 것을 확인 할 수 있습니다. 20
  • 21. 2.2 Docker Container Operations v Run Containers Container 를 실행 하는 명령 입니다. # docker run [OPTIONS] IMAGE [COMMAND] [ARG...] # docker run httpd AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message [Mon Sep 10 06:43:19.002515 2018] [mpm_event:notice] [pid 1:tid 140466418673536] AH00489: Apache/2.4.34 (Unix) configured -- resuming normal operations [Mon Sep 10 06:43:19.002612 2018] [core:notice] [pid 1:tid 140466418673536] AH00094: Command line: 'httpd -D FOREGROUND' 21
  • 22. 2.2 Docker Container Operations v Remove Containers 현재 실행 중이거나 실행이 종료된 Container 를 제거하는 명령 입니다. 현재 실행 중인 Container 를 강제로 제거 하기 위해서는 -f 옵션을 사용합니다. # docker rm [OPTIONS] CONTAINER [CONTAINER...] # docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c89632a2eede httpd "httpd-foreground" 2 minutes ago Exited (0) 2 minutes ago fervent_wiles 032759e31d4c hello-world "/hello" 10 days ago Exited (0) 10 days ago jovial_lovelace # docker rm c89632a2eede c89632a2eede # docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 032759e31d4c hello-world "/hello" 10 days ago Exited (0) 10 days ago jovial_lovelace 22
  • 24. 2.2 Docker Container Operations v Docker를 이용해서 Web 서비스 구성 앞서 배운 docker run 명령을 통해 Container 를 시작하고 Web 서비스를 구성 할 수 있습니다. 1) Docker 이미지 Pull 진행 # docker pull httpd Using default tag: latest latest: Pulling from library/httpd Digest: sha256:8631904c6e92918b6c7dd82b72512714e7fbc3f1a1ace2de17cb2746c401b8fb Status: Image is up to date for httpd:latest # docker images REPOSITORY TAG IMAGE ID CREATED SIZE httpd latest d595a4011ae3 5 days ago 178MB han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85kB 24
  • 25. 2.2 Docker Container Operations v Docker를 이용해서 Web 서비스 구성 앞서 배운 docker run 명령을 통해 Container 를 시작하고 Web 서비스를 구성 할 수 있습니다. 2) Docker Container 구동 25 Container 가 Foreground 로 작동하면서 Shell 을 사용을 못할 뿐더러, Shell 이 종료가 되면 httpd Container 도 중지가 됩니다. 위와 같이 되면, 전혀 서비스에 적용 할 수가 없습니다. 그리하여 아래와 같이 background 로 container 를 실행하면 됩니다.
  • 26. 2.2 Docker Container Operations v Docker를 이용해서 Web 서비스 구성 앞서 배운 docker run 명령을 통해 Container 를 시작하고 Web 서비스를 구성 할 수 있습니다. 3) Run Background Docker Container # docker run -d httpd 3c9764e9b79a058b0dedda07312679d6cafc0779c3e66ae04d9d1034a2b29ee1 # docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3c9764e9b79a httpd "httpd-foreground" 11 seconds ago Up 10 seconds 80/tcp stupefied_rama 26 위와 같이 Shell 에서 다른 명령도 가능하고 서비스가 계속 실행되는 것을 확인 할 수 있습니다. 그럼 실제로 서비스가 작동하는지 확인해 보겠습니다.
  • 27. 2.2 Docker Container Operations v Docker를 이용해서 Web 서비스 구성 앞서 배운 docker run 명령을 통해 Container 를 시작하고 Web 서비스를 구성 할 수 있습니다. 4) 서비스 확인 # curl http://127.0.0.1 curl: (7) Failed connect to 127.0.0.1; 연결이 거부됨 27
  • 28. 2.2 Docker Container Operations v Docker를 이용해서 Web 서비스 구성 § Docker Network 구조 28
  • 29. 2.2 Docker Container Operations v Docker를 이용해서 Web 서비스 구성 § Docker Network 구조 29
  • 30. 2.2 Docker Container Operations v Docker를 이용해서 Web 서비스 구성 # docker stop 3c9764e9b79a // 기존에 실행중이던 docker container 중지 3c9764e9b79a # docker ps –a // docker container 중지 확인 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3c9764e9b79a httpd “httpd-foreground” 18 minutes ago Exited (0) 3 seconds ago stupefied_raman # docker run –d –p 80:80 httpd // add option port mapping dee5fb60c083564d6095b1b9811b3e634c017caf9788f5fce57a0dcb309e4e76 # docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES dee5fb60c083 httpd "httpd-foreground" 3 seconds ago Up 2 seconds 0.0.0.0:80->80/tcp goofy_sammet 3c9764e9b79a httpd "httpd-foreground" 19 minutes ago Exited (0) 18 seconds ago stupefied_raman # curl http://127.0.0.1 // 서비스 확인 <html><body><h1>It works!</h1></body></html> 30
  • 31. 2.2 Docker Container Operations v Docker를 이용해서 Web 서비스 구성 31
  • 32. 2.2 Docker Container Operations v Docker를 이용해서 Web 서비스 구성 Index.html 수정 # docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES dee5fb60c083 httpd "httpd-foreground" 3 seconds ago Up 2 seconds 0.0.0.0:80->80/tcp goofy_sammet 3c9764e9b79a httpd "httpd-foreground" 19 minutes ago Exited (0) 18 seconds ago stupefied_raman # docker exec -ti dee5fb60c083 /bin/bash "container 내부로 들어가서 http index.html 을 수정합니다." root@dee5fb60c083:/usr/local/apache2# root@dee5fb60c083:/usr/local/apache2# ls bin build cgi-bin conf error htdocs icons include logs modules root@dee5fb60c083:/usr/local/apache2# cd htdocs/ root@dee5fb60c083:/usr/local/apache2/htdocs# ls index.html root@dee5fb60c083:/usr/local/apache2/htdocs# cat index.html <html><body><h1>It works!</h1></body></html> root@dee5fb60c083:/usr/local/apache2/htdocs# echo "<html><body><h1>Docker Test Page</h1></body></html>" > index.html root@dee5fb60c083:/usr/local/apache2/htdocs# cat index.html <html><body><h1>Docker Test Page</h1></body></html> root@dee5fb60c083:/usr/local/apache2/htdocs# exit Exit # curl http://192.168.13.131 <html><body><h1>Docker Test Page</h1></body></html> 32
  • 33. 2.2 Docker Container Operations v Docker를 이용해서 Web 서비스 구성 33
  • 34. 2.3 DockerFile v DockerFile 이란? DockerFile 이란, 나만의 Container image를 Build 할 수 있게 해주는 Docker image 파일 입니다. Docker Hub 에 없는 이미지도 DockerFile 을 이용하면 특별한 image 도 생성 할 수 있습니다. DockerFile # cat dockerfile FROM httpd:latest MAINTAINER chhan <chhan@osci.kr> RUN echo "<html><body><h1>Docker File Test Page</h1></body></html>" > /usr/local/apache2/htdocs/index.html EXPOSE 80 34
  • 35. 2.3 DockerFile v DockerFile 35 # cat dockerfile FROM httpd:latest MAINTAINER chhan <chhan@osci.kr> RUN echo "<html><body><h1>Docker File Test Page</h1></body></html>" > /usr/local/apache2/htdocs/index.html EXPOSE 80 • FROM Docker Hub 에서 어떤 이미지를 가지고 와서 작업할지 선언합니다. 작성법은 <이미지명>:<태그> 로 작성합니다. • MAINTAINER DockerFile 제작한 사람의 정보를 기입합니다. • RUN docker image 가 실행되고 container 내에서 실행될 명령어입니다. 해당 내용은 적으면 적을수록 container label 이 적게 생성되어 image 를 compact 하게 생성 할 수 있습니다. • EXPOSE Host 에 연결될 Port를 지정합니다. 위와 같은 DockerFile 구문을 자세히 확인하려면 아래 문서를 참고하시면 됩니다. ( https://docs.docker.com/engine/reference/builder/ )
  • 36. 2.3 DockerFile v DockerFile Build 36 # pwd /root/http # ls dockerfile # docker build -t myhttpd . Sending build context to Docker daemon 2.048kB Step 1/4 : FROM httpd:latest ---> d595a4011ae3 Step 2/4 : MAINTAINER chhan <chhan@osci.kr> ---> Running in 176d94e63272 Removing intermediate container 176d94e63272 ---> 282d30eba8fe Step 3/4 : RUN echo "<html><body><h1>Docker File Test Page</h1></body></html>" > /usr/local/apache2/htdocs/index.html ---> Running in 2f16f1ef9d1c Removing intermediate container 2f16f1ef9d1c ---> df135d6e6dbd Step 4/4 : EXPOSE 80 ---> Running in 12cdc41b8546 Removing intermediate container 12cdc41b8546 ---> 52c07f2bfb38 Successfully built 52c07f2bfb38 Successfully tagged myhttpd:latest
  • 37. 2.3 DockerFile v DockerFile Build 37 # docker images REPOSITORY TAG IMAGE ID CREATED SIZE myhttpd latest 52c07f2bfb38 3 seconds ago 178MB httpd latest d595a4011ae3 5 days ago 178MB han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85kB # docker run -d -p 80:80 --name=myweb myhttpd 1afd260265923828f88eeae9bc7083985b66eef2d9c588d35ee08e05198470a0 # docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1afd26026592 myhttpd "httpd-foreground" 5 seconds ago Up 5 seconds 0.0.0.0:80->80/tcp myweb # curl http://192.168.13.131 <html><body><h1>Docker File Test Page</h1></body></html> 이처럼 DockerFile 을 통해 작성한 container image 를 통해 매번 index File 이 수정된 Web 서비스를 실행 할 수 있습니다.
  • 39. 2.4 Docker-compose v docker-compose 로 Container 통합 관리 docker-compose 란, 한번에 여러 container 을 통합 관리 할 수 있게 하는 툴입니다. v docker-compose 설치 39 # curl -L "https://github.com/docker/compose/releases/download/1.22.0/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 100 617 0 617 0 0 558 0 --:--:-- 0:00:01 --:--:-- 559 100 11.2M 100 11.2M 0 0 2186k 0 0:00:05 0:00:05 --:--:-- 3668k # chmod +x /usr/local/bin/docker-compose # ls -l /usr/local/bin/docker-compose -rwxr-xr-x 1 root root 11750136 9월 10 17:26 /usr/local/bin/docker-compose # docker-compose --version docker-compose version 1.22.0, build f46880fe
  • 40. 2.4 Docker-compose v docker-compose 로 Container 통합 관리 docker-compose.yml 작성 40 version: '3.3' services: db: image: mysql:5.7 volumes: - /var/lib/mysql:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: passwordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: - db image: wordpress:latest ports: - "80:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress
  • 41. 2.4 Docker-compose v docker-compose 로 Container 통합 관리 docker-compose.yml 을 실행 (-f [File] , -d background 실행) 41 # docker-compose -f docker-compose.yml up -d
  • 42. 2.4 Docker-compose v docker-compose 로 Container 통합 관리 docker-compose.yml 을 실행 42 # ls -la /root/wordpress/docker-compose.yml -rw-r--r-- 1 root root 537 9월 10 17:35 /root/wordpress/docker-compose.yml # docker-compose -f docker-compose.yml up -d Creating network "wordpress_default" with the default driver Pulling db (mysql:5.7)... 5.7: Pulling from library/mysql 802b00ed6f79: Pull complete 30f19a05b898: Pull complete 3e43303be5e9: Pull complete 94b281824ae2: Pull complete 51eb397095b1: Pull complete 54567da6fdf0: Pull complete bc57ddb85cce: Pull complete c7c0a9c25d8a: Pull complete cce6c47ac3fc: Pull complete 499b9c7376c8: Pull complete 6c5e08e005ea: Pull complete Digest: sha256:1d8f471c7e2929ee1e2bfbc1d16fc8afccd2e070afed24805487e726ce601a6d Status: Downloaded newer image for mysql:5.7
  • 43. 2.4 Docker-compose v docker-compose 로 Container 통합 관리 docker-compose.yml 을 실행 43 Pulling wordpress (wordpress:latest)... latest: Pulling from library/wordpress 802b00ed6f79: Already exists 59f5a5a895f8: Pull complete 6898b2dbcfeb: Pull complete 8e0903aaa47e: Pull complete 2961af1e196a: Pull complete 71f7016f79a0: Pull complete 5e1a48e5719c: Pull complete 7ae5291984f3: Pull complete 725b65166f31: Pull complete 3823a607a5d4: Pull complete 1bcfa4198e39: Pull complete f1c79da21110: Pull complete 18903f439956: Pull complete 5eda25fffde3: Pull complete 3800dac98824: Pull complete 951fbb644962: Pull complete 5b91123e33c5: Pull complete 71250bb070e7: Pull complete 0363e75875b5: Pull complete 3bcb3cbf244a: Pull complete Digest: sha256:e30aed2d17b33758544f0eaebee763a452b41ff5bc926d723566338b0137dd81 Status: Downloaded newer image for wordpress:latest Creating wordpress_db_1 ... done Creating wordpress_wordpress_1 ... done
  • 44. 2.4 Docker-compose v docker-compose 로 Container 통합 관리 # docker-compose ps // docker-compose로 작동 중인 Container 현황 # docker-compose top // docker-compose 가 관리중인 Container Process 정보 44 # docker-compose ps Name Command State Ports ------------------------------------------------------------------------------------- wordpress_db_1 docker-entrypoint.sh mysqld Up 3306/tcp, 33060/tcp wordpress_wordpress_1 docker-entrypoint.sh apach ... Up 0.0.0.0:8000->80/tcp # docker-compose top wordpress_db_1 UID PID PPID C STIME TTY TIME CMD ------------------------------------------------------------- polkitd 10737 10716 0 17:41 ? 00:00:00 mysqld wordpress_wordpress_1 UID PID PPID C STIME TTY TIME CMD ------------------------------------------------------------------------ root 10997 10977 0 17:41 ? 00:00:00 apache2 -DFOREGROUND 33 14530 10997 0 17:41 ? 00:00:00 apache2 -DFOREGROUND 33 14531 10997 0 17:41 ? 00:00:00 apache2 -DFOREGROUND 33 14533 10997 0 17:41 ? 00:00:00 apache2 -DFOREGROUND 33 14534 10997 0 17:41 ? 00:00:00 apache2 -DFOREGROUND 33 14535 10997 0 17:41 ? 00:00:00 apache2 -DFOREGROUND
  • 45. 2.4 Docker-compose v docker-compose 로 Container 통합 관리 45
  • 46. 2.4 Docker-compose v docker-compose 로 Container 통합 관리 46 # docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 25c5e75bb07d wordpress:latest "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 0.0.0.0:8000->80/tcp wordpress_wordpress_1 f52a5d2495e4 mysql:5.7 "docker-entrypoint.s…" 4 minutes ago Up 4 minutes 3306/tcp, 33060/tcp wordpress_db_1 # docker images REPOSITORY TAG IMAGE ID CREATED SIZE myhttpd latest 52c07f2bfb38 About an hour ago 178MB wordpress latest 63b422244491 2 days ago 409MB mysql 5.7 563a026a1511 5 days ago 372MB httpd latest d595a4011ae3 5 days ago 178MB han0495/hello-world latest 2cb0d9787c4d 2 months ago 1.85k • Local 에 없던 image를 자동으로 Download 했습니다. • docker container 를 실행했습니다. • /var/lib/mysql 를 영구적 볼륨으로 할당하였습니다. • docker 내부 포트를 외부 포트와 Mapping 하였습니다. • container 를 순서대로 실행했습니다
  • 48. 3. 참고 자료 v 참고 자료 • Cgroup : https://access.redhat.com/documentation/ko- kr/red_hat_enterprise_linux/6/html/resource_management_guide/ch01 • namespace : https://access.redhat.com/documentation/en- us/red_hat_enterprise_linux_atomic_host/7/html/overview_of_containers_in_red_hat_systems/introduction_to_l inux_containers • docker : https://docs.docker.com/ • Sideshare • Google Image Search • docker lab : https://training.play-with-docker.com/ 48