๐ŸŒฑ Infra/Container_Docker 13

[Docker-Basic (12)] Docker Compose Sample App - Django

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” ์•„๋ž˜ URL์„ ์ฐธ์กฐํ•˜์—ฌ Django+postgresql ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‹คํ–‰ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค :) docs.docker.com/compose/django/ Quickstart: Compose and Django This quick-start guide demonstrates how to use Docker Compose to set up and run a simple Django/PostgreSQL app. Before starting, install Compose. Define the project components For this project, you... docs.docker.com ๐Ÿณ Step1. ํ”„๋กœ์ ํŠธ ๊ตฌ์„ฑ์š”์†Œ ์ •์˜ 1. ํ”„๋กœ์ ํŠธ(์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜) ๋ฃจํŠธ ๋””๋ ‰ํ† ๋ฆฌ ์ƒ์„ฑ ํ”„๋กœ์ ํŠธ์—์„œ..

[Docker-Basic (11)] Docker Compuser ์‚ฌ์šฉํ•˜๊ธฐ :P

Docker Compose๋Š”, ์—ฌ๋Ÿฌ๊ฐœ์˜ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์ •์˜ํ•˜๊ณ  ์‹คํ–‰ํ•˜๊ธฐ ์œ„ํ•œ ๋„๊ตฌ์ž…๋‹ˆ๋‹ค. ์ฆ‰, ํ•œ๋ฒˆ์— 2๊ฐœ ์ด์ƒ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ํ•˜๋‚˜์˜ ์„ธํŠธ์ฒ˜๋Ÿผ ์‹คํ–‰ํ•ด์•ผ ํ•œ๋‹ค๋ฉด Docker Compose๋ฅผ ์‚ฌ์šฉํ•ด๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ง›๋ณด๊ธฐ๋กœ ํ•œ๋ฒˆ ์ง„ํ–‰ ํ•ด๋ด…์‹œ๋‹ค! ๐Ÿณ step 1. Compose ์„ค์น˜ ๋„์ปค ์„ค์น˜ ๋ช…๋ น์–ด๋ถ€ํ„ฐ ๋น ๋ฅด๊ฒŒ ๋‹ค์‹œ ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๊ณต์‹ํ™ˆํŽ˜์ด์ง€์—์„œ๋„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 1. Docker ์„ค์น˜ Docker๊ฐ€ ์„ค์น˜๋  OS๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. ์ €๋Š” Centos7 ์— ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค :) [root@master /]# rpm -qa | grep release centos-release-7-8.2003.0.el7.centos.x86_64 yum-utils ๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค. [root@master /]# yum install -y yum-u..

[Docker-Basic (10)] Docker File ์‚ฌ์šฉํ•˜๊ธฐ - ์‹ค์Šต2 MARIA DB

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๋ถ€๋ถ„์ค‘ ํ•˜๋‚˜์ธ DockerFile์— ๋Œ€ํ•ด์„œ ๋‹ค๋ฃจ์–ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!!! ์‹œ์ž‘ํ•˜๊ธฐ์ „์—, ๋„์ปคํŒŒ์ผ์ด๋ž€ ๋ญ˜๊นŒ์š”? docs.docker.com/engine/reference/builder/ Dockerfile reference Docker can build images automatically by reading the instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command... docs.docker.com ๊ฐ„๋‹จํ•˜๊ฒŒ "๋ ˆ์‹œํ”ผ"๋ผ๊ณ  ๋ณผ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์š”๋ฆฌ๋ฅผ ๋งŒ๋“ค๋–„ ์–ด๋–ป๊ฒŒ ๋งŒ๋“ค์–ด์•ผ ๋ง›์žˆ๋Š”์ง€ ๋ ˆ์‹œํ”ผ๋ฅผ ์ •๋ฆฌํ•˜์—ฌ ์ •์˜๋œ ..

[Docker-Basic (9)] Docker File ์‚ฌ์šฉํ•˜๊ธฐ -์‹ค์Šต1 HTTP ์›น

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๋ถ€๋ถ„์ค‘ ํ•˜๋‚˜์ธ DockerFile์— ๋Œ€ํ•ด์„œ ๋‹ค๋ฃจ์–ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค!!! ์‹œ์ž‘ํ•˜๊ธฐ์ „์—, ๋„์ปคํŒŒ์ผ์ด๋ž€ ๋ญ˜๊นŒ์š”? docs.docker.com/engine/reference/builder/ Dockerfile reference Docker can build images automatically by reading the instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command... docs.docker.com ๊ฐ„๋‹จํ•˜๊ฒŒ "๋ ˆ์‹œํ”ผ"๋ผ๊ณ  ๋ณผ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์š”๋ฆฌ๋ฅผ ๋งŒ๋“ค๋–„ ์–ด๋–ป๊ฒŒ ๋งŒ๋“ค์–ด์•ผ ๋ง›์žˆ๋Š”์ง€ ๋ ˆ์‹œํ”ผ๋ฅผ ์ •๋ฆฌํ•˜์—ฌ ์ •์˜๋œ ..

[Docker-Basic (8)] Container Image ๊ด€๋ฆฌํ•˜๊ธฐ

์ด๋ฒˆํฌ์ŠคํŒ…์—์„œ๋Š” ์ด๋ฏธ์ง€์— ๋Œ€ํ•œ ๊ธฐ๋ณธ ๋‚ด์šฉ์„ ๋‹ค๋ฃจ๊ฒ ์Šต๋‹ˆ๋‹ค. ์‹œ์ž‘ํ•˜๊ธฐ์ „์—, ๋ชจ๋“  ๋„์ปค ์ด๋ฏธ์ง€์™€ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‚ญ์ œํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ํ—ท๊ฐˆ๋ฆด์ˆ˜์žˆ์œผ๋‹ˆ๊นŒ์š”! ๋จผ์ € ์ปจํ…Œ์ด๋„ˆ ์ „์ฒด ์‚ญ์ œ! [root@docker-master /]# docker rm -f $(docker ps -aq) 2bf8c98f110d ๊ทธ๋‹ค์Œ ์ด๋ฏธ์ง€๋„ ๋ชจ๋‘ ์‚ญ์ œํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค! [root@docker-master /]# docker rmi -f $(docker images -q) Untagged: registry:2 Untagged: registry@sha256:8be26f81ffea54106bae012c6f349df70f4d5e7e2ec01b143c46e2c03b9e551d Deleted: sha256:2d4f4b5309b1e41b4f83ae59b44df6d6..

[Docker-Basic (7)] Container Image Registry ๊ตฌ์„ฑ

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” 2๊ฐœ์˜ ํ˜ธ์ŠคํŠธ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ํ•˜๋‚˜๋Š” Master Node๋กœ Registry ์„œ๋ฒ„ ์—ญํ• ์„ ํ•  ๋…ธ๋“œํžˆ๊ณ , ํ•˜๋‚˜๋Š” Worker Node๋กœ Registry์— ์ด๋ฏธ์ง€๋ฅผ Pull/Push ํ•  ๋…ธ๋“œ์ž…๋‹ˆ๋‹ค ์ €๋Š” AWS EC2๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ตฌ์„ฑํ•˜์˜€์Šต๋‹ˆ๋‹ค :) 1. Docker Registry ์„ค์ •ํ•˜๊ธฐ 1-1) Master Node ํ™•์ธ ๋‘๊ฐœ์˜ ํ˜ธ์ŠคํŠธ ์ค‘ ๋จผ์ € Mager ๋…ธ๋“œ์˜ ์„ค์ •์„ ํ™•์ธํ•ด๋ด…๋‹ˆ๋‹ค :) ๋จผ์ €, Hostname์„ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. (ํ˜ธ์ŠคํŠธ ์ด๋ฆ„ ๋ณ€๊ฒฝ์€ #hostnamectl set-hostname ๋ช…๋ น์–ด๋กœ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค) [root@docker-master /]# hostnamectl Static hostname: docker-master.test.dom Icon name: computer-vm..

[Docker-Basic (6)] Container Storage (volume)

์ปจํ…Œ์ด๋„ˆ์˜ ์Šคํ† ๋ฆฌ์ง€(๋ณผ๋ฅจ)์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๊ณ , ์‹ค์Šตํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ๋„์ปค ์ด๋ฏธ์ง€๋กœ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์ƒ์„ฑํ•˜๋ฉด, ๊ทธ ์ด๋ฏธ์ง€๋Š” ์ฝ๊ธฐ ์ „์šฉ์œผ๋กœ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ์šด์˜์ค‘์ธ ์ปจํ…Œ์ด๋„ˆ์— ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•ด๋„, ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ์ข…๋ฃŒ๋˜๋ฉด ๋ชจ๋‘ ์‚ฌ๋ผ์ง€๊ฒŒ ๋˜๋Š”๊ฑฐ์ฃ . ์ด๋Ÿฐ ์ปจํ…Œ์ด๋„ˆ์˜ ํŠน์„ฑ๋•Œ๋ฌธ์—, ์˜๊ตฌ์ ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์Šคํ† ๋ฆฌ์ง€๋ฅผ ๋งˆ์šดํŠธ ํ•˜์—ฌ ์‚ฌ์šฉํ•  ์ˆ˜์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. :) Docker์˜ ์˜๊ตฌ ์Šคํ† ๋ฆฌ์ง€(๋ณผ๋ฅจ) ๋Š” ๋„์ปค๋ณผ๋ฅจ, ํ˜ธ์ŠคํŠธ, ๋ณผ๋ฅจ์ปจํ…Œ์ด๋„ˆ ์ด๋ ‡๊ฒŒ 3๊ฐ€์ง€๋กœ ๊ตฌ๋ถ„๋ฉ๋‹ˆ๋‹ค. ๊ฐ ์‹ค์Šต์„ ํ†ตํ•ด ์ž์„ธํžˆ ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. 1. Docker Storage - Docker Volume ๋„์ปค ๋ณผ๋ฅจ์€ ๋„์ปค ์ž์ฒด์—์„œ ์ œ๊ณตํ•˜๋Š” ๋ณผ๋ฅจ ๊ธฐ๋Šฅ์ž…๋‹ˆ๋‹ค. 1-1) Docker Volume ์ƒ์„ฑ ๋ฐ ํ• ๋‹น ๋จผ์ € Docker Volume์„ ๋จผ์ € ํ…Œ์ŠคํŠธ ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. d..

[Docker-Basic (5)] Container Network

์ปจํ…Œ์ด๋„ˆ์˜ ๋„คํŠธ์›Œํฌ์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๊ณ , ์‹ค์Šตํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. Docker Network ๋Š” ๋ธŒ๋ฆฌ์ง€(Bridge),ํ˜ธ์ŠคํŠธ(host), ์ปจํ…Œ์ด๋„ˆ(container), ๋…ผ(none) ์ด๋ ‡๊ฒŒ 4๊ฐ€์ง€๋กœ ๊ตฌ๋ถ„๋ฉ๋‹ˆ๋‹ค. ์•„๋ž˜ 3๊ฐ€์ง€ ๋ฐฉ์‹๋งŒ ๋ณด์ด๋Š”๋ฐ, ์ปจํ…Œ์ด๋„ˆ ๋ฐฉ์‹์€ ๋ณ„๋„๋กœ ๋“œ๋ผ์ด๋ฒ„๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ธฐ๋•Œ๋ฌธ์— ๋‚˜์˜ค์ง€ ์•Š์Šต๋‹ˆ๋‹ค. [root@docker /]# docker network ls NETWORK ID NAME DRIVER SCOPE 103b63dc3b48 bridge bridge local db3d9f5b68d6 host host local 3a8a3fc8dbd7 none null local ๊ฐ ์‹ค์Šต์„ ํ†ตํ•ด ์–ด๋–ป๊ฒŒ ๋‹ค๋ฅธ์ง€ ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. 1. Docker Network - Bridge docker์˜ ๊ธฐ๋ณธ ๋„ค..

[Docker-Basic (4)] Container Quota ์‚ฌ์šฉํ•˜๊ธฐ

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” ์ปจํ…Œ์ด๋„ˆ์— CPU, Memory๋ฅผ ํ• ๋‹นํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค. 1. ์ปจํ…Œ์ด๋„ˆ ๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹น 1-1 ) ์ปจํ…Œ์ด๋„ˆ์— ๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹นํ•˜๊ธฐ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‹œ์ž‘ํ• ๋•Œ ์ปจํ…Œ์ด๋„ˆ์—์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ฆฌ์†Œ์Šค ํฌ๊ธฐ๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค :) ๋จผ์ € ๋ฉ”๋ชจ๋ฆฌ๋ฅผ 100m ์ง€์ •ํ•˜์—ฌ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‹คํ–‰ํ•ด๋ด…์‹œ๋‹ค. [root@docker /]# docker run --name nginx -d -p 8080:80 --memory="100m" nginx 9fc9ccbf2a551a2bd4911d096a545b105c63762f9affb900390431a3df0402a0 docker inspect ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ปจํ…Œ์ด๋„ˆ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ์ •๋ณด๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ปจํ…Œ์ด๋„ˆ์— ์ •๋ง ๋ฉ”๋ชจ๋ฆฌ ํ• ๋‹น๋Ÿ‰์ด ์„ค์ • ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•ด๋ด…๋‹ˆ๋‹ค. [root@do..

[Docker-Basic (๋ฒˆ์™ธ)] Docker Container Configure File

์ด๋ฒˆ ์‹ค์Šต์—์„œ ๋‹ค๋ฃฐ ๋‚ด์šฉ์€ ํฌ๊ฒŒ ์ค‘์š”ํ•˜์ง€๋Š” ์•Š์ง€๋งŒ ์–ธ์  ๊ฐ€ ํ•„์š”ํ• ์ˆ˜๋„ ์žˆ๊ธฐ๋•Œ๋ฌธ์— ๋ณ„๋„ ๋ฒˆ์™ธ๋กœ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค :) ๋„์ปค ํ”„๋กœ์„ธ์Šค๋ฅผ ์ •์˜ํ•˜๋Š” ํŒŒ์ผ์— ์ง์ ‘ ๋“ค์–ด๊ฐ€์„œ ๋‚ด์šฉ์„ ์ˆ˜์ •ํ•˜๋Š” ์‹ค์Šต์„ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์ž, ํ•œ๋ฒˆ ํ•ด๋ด…์‹œ๋‹ค! ๐Ÿ˜Ž ๋„์ปค ์ปจํ…Œ์ด๋„ˆ๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. [root@docker /]# docker container run --name nginx -d -p 8080:80 nginx d66376e534babcd49e947d2766c01dac442a1c0daaa3d3f7643434b05bc210ae ๋ชฉ๋ก์„ ํ™•์ธํ•ด๋ด…์‹œ๋‹ค. root@docker /]# docker container ls -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d66376e534ba nginx "/..

728x90