IT STUDY LOG
[Docker] 02. Docker CLI 본문
# 학습 목표
- 컨테이너 기술이 무엇인지, Docker가 왜 필요한지 알 수 있다.
- 컨테이너와 이미지, 레지스트리가 무엇인지 이해할 수 있다.
- 대표적인 레지스트리인 Docker Hub에서 이미지를 검색하고, 사용할 수 있다.
- 한 개의 이미지를 이용해서 컨테이너를 구축할 수 있다.
- 두 개 이상의 이미지를 이용해서 컨테이너를 구축하고 서로가 어떻게 연결되는지 알 수 있다.
- Docker CLI에서 명령어를 사용해서 이미지를 생성/수정/배포하고, 컨테이너를 생성/삭제할 수 있다.
- Dockerfile을 이용해 이미지를 생성할 수 있다.
- 애플리케이션을 컨테이너화할 수 있다.
# 학습 내용
1. Docker CLI
Docker CLI(Command Line Interface)
docker container run
docker container run: See [docker run](run.md) for more information.
docs.docker.com
- 사용법(Docker CLI, Docker-Compose CLI, API Reference) 및 환경 및 빌드 파일 구성(DockerFile, Docker-Compose File) 관련 정보 확인 가능
도커 이용하기
레지스트리(Registry)
- Docker Hub : https://hub.docker.com/
Docker Hub Container Image Library | App Containerization
Deliver your business through Docker Hub Package and publish apps and plugins as containers in Docker Hub for easy download and deployment by millions of Docker users worldwide.
hub.docker.com
- 도커 이미지를 관리하는 공간
- 특별히 지정하지 않을 경우 도커 허브(Docker Hub)가 기본 레지스트리로 설정됨
- 레지스트리는 Docker Hub, Private Docker Hub, 회사 내부용 레지스트리 등으로 분류 가능
레포지토리(Repository)
- 레지스트리 내에 도커 이미지가 저장되는 공간
- 이미지 이름이 사용되기도 함
- GitHub의 레포지토리와 유사
태그(Tag)
- 같은 이미지라고 할지라도 버전 별로 안의 내용이 조금은 다를 수 있으므로 해당 이미지를 설명하는 버전 정보를 주로 입력
- 특별히 버전을 명시하지 않을 경우 latest 태그를 붙인 이미지를 가져 옴
레지스트리의 이미지를 사용하는 방법?
- 해당 레지스트리에서 해당 이미지의 안내 페이지를 참고
Step 1 : 도커 이미지를 가져오기
# 현재 내 도커에 존재하는 이미지 리스트 확인
$ sudo docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 18 months ago 13.3kB
# 레지스트리로부터 최신 이미지를 받기
$ sudo docker image pull docker/whalesay:latest
latest: Pulling from docker/whalesay
Image docker.io/docker/whalesay:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/
e190868d63f8: Pull complete
909cd34c6fd7: Pull complete
0b9bfabab7c1: Pull complete
a3ed95caeb02: Pull complete
00bf65475aba: Pull complete
c57b6bcc83e3: Pull complete
8978f6879e2f: Pull complete
8eed3712d2cf: Pull complete
Digest: sha256:178598e51a26abbc958b8a2e48825c90bc22e641de3d31e18aaf55f3258ba93b
Status: Downloaded newer image for docker/whalesay:latest
docker.io/docker/whalesay:latest
Step 2 : 받아온 이미지를 실행해 컨테이너 올리기
docker [container] run [--name 컨테이너_이름] registry_account/repository_name:tag
- [container] run : 컨테이너 실행
- options : -- name의 경우 컨테이너 이름 할당
- command : 초기 컨테이너 실행 시 수행되는 명령어. cowsay : 컨테이너 실행시 cowsay 명령어를 호출(as like 노드 호출)
- [ARG...] : boo: COMMAND인 cowsay에 넘겨질 파라메터
$ docker container run --name whalesay docker/whalesay:latest cowsay 고래고래
______________
< 고래고래 >
--------------
\
\
\
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
Step 3 : 컨테이너 리스트 출력하기
docker [container] ps - a
- [container] ps : 컨테이너 리스트를 출력
- [options] : -a의 경우 종료된 컨테이너를 포함해 모든 컨테이너를 출력
$ docker container ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
714f5b4e0679 docker/whalesay:latest "cowsay 고래고래" 47 seconds ago Exited (0) 45 seconds ago whalesay
f31f3aa3629e hello-world "/hello" 2 hours ago Exited (0) 2 hours ago happy_swanson
521b7a34df7b hello-world "/hello" 2 weeks ago Exited (0) 2 weeks ago zealous_brahmagupta
997e8d07e77d hello-world "/hello" 2 weeks ago Exited (0) 2 weeks ago condescending_wright
Step 4 : 컨테이너를 삭제하기
docker [container] rm whalesay
> [container] rm : 컨테이너를 지정해 삭제, 컨테이너를 명시할 때는 ps 명령어를 통해 확인할 수 있는 names 혹은 container id를 사용
$ docker container rm whalesay
whalesay
$ docker container ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f31f3aa3629e hello-world "/hello" 2 hours ago Exited (0) 2 hours ago happy_swanson
521b7a34df7b hello-world "/hello" 2 weeks ago Exited (0) 2 weeks ago zealous_brahmagupta
997e8d07e77d hello-world "/hello" 2 weeks ago Exited (0) 2 weeks ago condescending_wright
Step 5 : 이미지의 용량을 확인하고 이미지 지우기
docker image ls
- docker image의 용량 확인
docker image rm 이미지명 (=docker rmi 이미지명)
- docker 이미지를 특정하여 지우기
$ docker container run --name roheerumi docker/whalesay:latest cowsay 까꿍
________
< 까꿍 >
--------
\
\
\
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
# image 용량 확인
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 18 months ago 13.3kB
docker/whalesay latest 6b362a9f73eb 7 years ago 247MB
# container가 기동 중이면 image를 삭제할 수 없음
$ docker image rm docker/whalesay
Error response from daemon: conflict: unable to remove repository reference "docker/whalesay" (must force) - container a8a047e2a293 is using its referenced image 6b362a9f73eb
# container를 먼저 제거하고 삭제
$ docker container rm roheerumi
roheerumi
$ docker image rm docker/whalesay:latest
Untagged: docker/whalesay:latest
Untagged: docker/whalesay@sha256:178598e51a26abbc958b8a2e48825c90bc22e641de3d31e18aaf55f3258ba93b
Deleted: sha256:6b362a9f73eb8c33b48c95f4fcce1b6637fc25646728cf7fb0679b2da273c3f4
Deleted: sha256:34dd66b3cb4467517d0c5c7dbe320b84539fbb58bc21702d2f749a5c932b3a38
Deleted: sha256:52f57e48814ed1bb08a651ef7f91f191db3680212a96b7f318bff0904fed2e65
Deleted: sha256:72915b616c0db6345e52a2c536de38e29208d945889eecef01d0fef0ed207ce8
Deleted: sha256:4ee0c1e90444c9b56880381aff6455f149c92c9a29c3774919632ded4f728d6b
Deleted: sha256:86ac1c0970bf5ea1bf482edb0ba83dbc88fefb1ac431d3020f134691d749d9a6
Deleted: sha256:5c4ac45a28f91f851b66af332a452cba25bd74a811f7e3884ed8723570ad6bc8
Deleted: sha256:088f9eb16f16713e449903f7edb4016084de8234d73a45b1882cf29b1f753a5a
Deleted: sha256:799115b9fdd1511e8af8a8a3c8b450d81aa842bbf3c9f88e9126d264b232c598
Deleted: sha256:3549adbf614379d5c33ef0c5c6486a0d3f577ba3341f573be91b4ba1d8c60ce4
Deleted: sha256:1154ba695078d29ea6c4e1adb55c463959cd77509adf09710e2315827d66271a
# 정상적으로 image 삭제됨
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 18 months ago 13.3kB
# container 프로세스도 동작하지 않음
$ docker container ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Step 6 : 이미지를 받고, 컨테이너를 실행하고, 컨테이너를 지우는 과정을 한 번에 수행하기
$ docker container run --name test --rm docker/whalesay cowsay all-in-one
Unable to find image 'docker/whalesay:latest' locally
latest: Pulling from docker/whalesay
Image docker.io/docker/whalesay:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/
e190868d63f8: Pull complete
909cd34c6fd7: Pull complete
0b9bfabab7c1: Pull complete
a3ed95caeb02: Pull complete
00bf65475aba: Pull complete
c57b6bcc83e3: Pull complete
8978f6879e2f: Pull complete
8eed3712d2cf: Pull complete
Digest: sha256:178598e51a26abbc958b8a2e48825c90bc22e641de3d31e18aaf55f3258ba93b
Status: Downloaded newer image for docker/whalesay:latest
____________
< all-in-one >
------------
\
\
\
## .
## ## ## ==
## ## ## ## ===
/""""""""""""""""___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\______/
$ docker container ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f31f3aa3629e hello-world "/hello" 5 hours ago Exited (0) 5 hours ago happy_swanson
521b7a34df7b hello-world "/hello" 2 weeks ago Exited (0) 2 weeks ago zealous_brahmagupta
997e8d07e77d hello-world "/hello" 2 weeks ago Exited (0) 2 weeks ago condescending_wright
# 컨테이너만 1회성으로 실행(컨테이너가 중지/종료될 때 컨테이너 관련 리소스 모두 제거)했으므로 이미지는 별도로 삭제해주어야 함
$ docker image rm docker/whalesay:latest
Untagged: docker/whalesay:latest
Untagged: docker/whalesay@sha256:178598e51a26abbc958b8a2e48825c90bc22e641de3d31e18aaf55f3258ba93b
Deleted: sha256:6b362a9f73eb8c33b48c95f4fcce1b6637fc25646728cf7fb0679b2da273c3f4
Deleted: sha256:34dd66b3cb4467517d0c5c7dbe320b84539fbb58bc21702d2f749a5c932b3a38
Deleted: sha256:52f57e48814ed1bb08a651ef7f91f191db3680212a96b7f318bff0904fed2e65
Deleted: sha256:72915b616c0db6345e52a2c536de38e29208d945889eecef01d0fef0ed207ce8
Deleted: sha256:4ee0c1e90444c9b56880381aff6455f149c92c9a29c3774919632ded4f728d6b
Deleted: sha256:86ac1c0970bf5ea1bf482edb0ba83dbc88fefb1ac431d3020f134691d749d9a6
Deleted: sha256:5c4ac45a28f91f851b66af332a452cba25bd74a811f7e3884ed8723570ad6bc8
Deleted: sha256:088f9eb16f16713e449903f7edb4016084de8234d73a45b1882cf29b1f753a5a
Deleted: sha256:799115b9fdd1511e8af8a8a3c8b450d81aa842bbf3c9f88e9126d264b232c598
Deleted: sha256:3549adbf614379d5c33ef0c5c6486a0d3f577ba3341f573be91b4ba1d8c60ce4
Deleted: sha256:1154ba695078d29ea6c4e1adb55c463959cd77509adf09710e2315827d66271a
Step 7 : 다른 이미지를 받아 실행해보고 종료하기
-run 명령어에 -i, -t 옵션을 동시에 사용할 경우 사용자와 컨테이너 간에 인터렉션(interaction)이 가능 (ex. 이 예제에서 처럼 출력되는 화면을 사용자가 지속적으로 보기 위해서 사용)
- 예를 들어 Python 명령이 필요하거나 추가로 다른 입력을 받는다면 해당 옵션을 지정한 뒤 사용
- 실행중인 컨테이너는 ctrl + c로 종료할 수 있음
$ docker container run -it --rm danielkraic/asciiquarium:latest
Unable to find image 'danielkraic/asciiquarium:latest' locally
latest: Pulling from danielkraic/asciiquarium
2ec1fbfd44b7: Pull complete
05fa48dc8a10: Pull complete
Digest: sha256:a9aaa046d674a28cd9d5091e7946c4885d27ac9ead48ce7b7ff5c12c7917fa4d
Status: Downloaded newer image for danielkraic/asciiquarium:latest
# rmi 명령어를 이용해 삭제
$ docker rmi danielkraic/asciiquarium:latest
Untagged: danielkraic/asciiquarium:latest
Untagged: danielkraic/asciiquarium@sha256:a9aaa046d674a28cd9d5091e7946c4885d27ac9ead48ce7b7ff5c12c7917fa4d
Deleted: sha256:7bab964067d2af9f5438194a7184de2e2edbc94b0e567466625004f67870d2cc
Deleted: sha256:a5b5b0bc65280271ddac7d7ff3071ea2caa9225b6608dd6d4e3e9bc6018df166
Deleted: sha256:97b94d418dac4ec6da11f188c162831ddf674b08c496d1fd9ebaf5d497f94e08
2. Docker CLI - Copy, Dockerfile
Docker 컨테이너에 파일을 복사하기
- 다른 사람이 제공한 도커 이미지를 받아 사용하는 경우, 원하는 모든 기능이 구성되어 있지 않을 수 있음
도커 이미지에 파일을 추가, 도커 이미지 생성하기
- 웹 서버는 도커 컨테이너로 실행하고 웹 서버를 구성하는 파일은 직접 만들거나 가져와 파일 구성
- 장점
> 서버 문제 생기는 것을 호스트와 별개로 파악 가능
> 문제가 생긴 서버를 종료하고 마치 공장 초기화를 하듯 도커 이미지로 서버 재구동이 가능
로컬에 있는 파일과 도커 이미지를 연결하는 방법
- CP(Copy) : 호스트와 컨테이너 사이에 파일을 복사
- Docker Volume : 호스트와 컨테이너 사이에 공간을 마운트 (저장 공간을 다른 장치에서 접근할 수 있도록 경로를 허용해 하나의 저장 공간을 이용하는 것처럼 보이게 하는 작업)
Step 1 : httpd(http daemon, Apach HTTP Server 실행 가능한 오픈소스 웹 서버 소프트웨어) 웹 서버 도커 이미지를 사용하기
(1) 게임 서버 파일을 로컬에 git clone
$ git clone git@github.com:codestates/pacman-canvas.git
'pacman-canvas'에 복제합니다...
remote: Enumerating objects: 1123, done.
remote: Counting objects: 100% (30/30), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 1123 (delta 9), reused 22 (delta 7), pack-reused 1093
오브젝트를 받는 중: 100% (1123/1123), 14.76 MiB | 4.83 MiB/s, 완료.
델타를 알아내는 중: 100% (639/639), 완료.
(2) docker container run 명령어로 httpd를 실행
- p 옵션 : 로컬호스트의 포트와 컨테이너 포트 연결 (ex. -p 818:80의 경우 818이 로컬호스트 포트, 80은 컨테이너 포트)
$ docker container run --name httpdserver --rm -p 818:80 httpd
Unable to find image 'httpd:latest' locally
latest: Pulling from library/httpd
f1f26f570256: Pull complete
a6b093ae1967: Pull complete
6b400bbb27df: Pull complete
6e310dd059b6: Pull complete
471cb5914961: Pull complete
Digest: sha256:4055b18d92fd006f74d4a2aac172a371dc9a750eaa78000756dee55a9beb4625
Status: Downloaded newer image for httpd:latest
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
[Tue Apr 11 00:23:49.423131 2023] [mpm_event:notice] [pid 1:tid 140495414705472] AH00489: Apache/2.4.57 (Unix) configured -- resuming normal operations
[Tue Apr 11 00:23:49.423408 2023] [core:notice] [pid 1:tid 140495414705472] AH00094: Command line: 'httpd -D FOREGROUND'
[Tue Apr 11 00:24:01.821809 2023] [mpm_event:notice] [pid 1:tid 140495414705472] AH00492: caught SIGWINCH, shutting down gracefully
- d 옵션 : 컨테이너를 백그라운드에서 실행
# docker container run 명령어에 -d 옵션 추가
$ docker container run --name httpdserver --rm -p 818:80 -d httpd
8e7d5e216f9e97865e16624e822d41cce506cc7f26208a6087806de137646383
# 프로세스 확인
$ ps -ef | grep "httpd"
root 3003 2980 0 09:25 ? 00:00:00 httpd -DFOREGROUND
www-data 3030 3003 0 09:25 ? 00:00:00 httpd -DFOREGROUND
www-data 3031 3003 0 09:25 ? 00:00:00 httpd -DFOREGROUND
www-data 3032 3003 0 09:25 ? 00:00:00 httpd -DFOREGROUND
roheeru+ 3121 2108 0 09:25 pts/0 00:00:00 grep --color=auto httpd
# 도커 컨테이너 확인
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8e7d5e216f9e httpd "httpd-foreground" 32 seconds ago Up 31 seconds 0.0.0.0:818->80/tcp, :::818->80/tcp httpdserver
# 포트 확인
$ sudo netstat -antp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:818 0.0.0.0:* LISTEN 2958/docker-proxy
tcp6 0 0 :::818 :::* LISTEN 2964/docker-proxy
tcp6 0 0 :::80 :::* LISTEN 918/apache2
(3) 브라우저에서 웹 서버 컨테이너가 정상적으로 실행되었는지 확인
Step 2 : 서버가 정상적으로 구동되었다면, 새로운 터미널에서 docker container cp 명령어를 통해 로컬호스트에 있는 파일을 컨테이너에 전달
docker container cp ./ 컨테이너_이름:/usr/local/apache2/htdocs/
- 상대 경로, 절대 경로에 주의
- 앞 경로의 파일을 뒤에 명시되는 경로에 복사
$ pwd
/{...}/pacman-canvas
# 현재 경로를 httpdserver 컨테이너의 /usr/local/apache2/htdocs 디렉터리에 복사
$ docker container cp ./ httpdserver:/usr/local/apache2/htdocs/
Preparing to copy...
Copying to container - 32.77kB
Copying to container - 65.54kB
# ... 중략 ... #
Copying to container - 17.27MB
Copying to container - 17.28MB
Successfully copied 17.28MB to httpdserver:/usr/local/apache2/htdocs/
docker inspect 컨테이너명
# 컨테이너 내부 구조가 어떻게 구성되었는지 inspect
$ docker inspect httpdserver
[
{
# ... 상략 ... #
"Env": [
"PATH=/usr/local/apache2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"HTTPD_PREFIX=/usr/local/apache2",
"HTTPD_VERSION=2.4.57",
# ... 하략 ...#
}
]
# container 내부 터미널로 접속하기
$ docker exec -it httpdserver bash
root@8e7d5e216f9e:/usr/local/apache2# pwd
/usr/local/apache2
root@8e7d5e216f9e:/usr/local/apache2# ls
bin build cgi-bin conf error htdocs icons include logs modules
root@8e7d5e216f9e:/usr/local/apache2# cd htdocs/
root@8e7d5e216f9e:/usr/local/apache2/htdocs# ls
Dockerfile data index.html package.json server.js
README.md fonts js pacman-canvas.css style.css
ads.txt googlee6aee5a894225e60.html manifest.json pacman-canvas.js wav
bump_version.sh httpd.conf mp3 pacman-canvas.test.js web-app-manifest.json
cache.manifest img package-lock.json pacman-canvas.webapp webpack.config.js
Step 3 : 게임 서버 구동 확인
Docker 이미지 만들기
- 이미지 생성의 장점 : 이전에 작업했던 내용을 재수행할 필요성이 없고 배포 및 관리가 유용
방법 1 : 구동한 Docker Container를 이미지로 만들기
(1) docker container commit 명령 사용
docker container commit 컨테이너명 지정할_이미지명:tag
$ docker container commit httpdserver my_pacman:1.0
sha256:d0383a73b2c46b9a0191b7d37783feb8f3b98f8011995cbafa96e72054e6feeb
- 생성된 이미지 조회
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my_pacman 1.0 d0383a73b2c4 5 seconds ago 162MB
httpd latest dc1a95e13784 4 days ago 145MB
(2) 만든 이미지를 포트에서 웹 서버로 구동
docker run --name 컨테이너명 -p 900:80 이미지명:tag
$ docker run --name my_web_test -p 900:80 my_pacman:1.0
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. 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.3. Set the 'ServerName' directive globally to suppress this message
[Tue Apr 11 01:08:18.848372 2023] [mpm_event:notice] [pid 1:tid 140686777482560] AH00489: Apache/2.4.57 (Unix) configured -- resuming normal operations
[Tue Apr 11 01:08:18.848603 2023] [core:notice] [pid 1:tid 140686777482560] AH00094: Command line: 'httpd -D FOREGROUND'
172.17.0.1 - - [11/Apr/2023:01:08:30 +0000] "GET / HTTP/1.1" 200 10268
172.17.0.1 - - [11/Apr/2023:01:08:30 +0000] "GET /style.css HTTP/1.1" 200 9997
172.17.0.1 - - [11/Apr/2023:01:08:30 +0000] "GET /pacman-canvas.css HTTP/1.1" 200 4594
172.17.0.1 - - [11/Apr/2023:01:08:30 +0000] "GET /js/jquery.hammer.min.js HTTP/1.1" 200 13005
172.17.0.1 - - [11/Apr/2023:01:08:30 +0000] "GET /js/jquery-1.10.2.min.js HTTP/1.1" 200 93107
172.17.0.1 - - [11/Apr/2023:01:08:30 +0000] "GET /pacman-canvas.js HTTP/1.1" 200 46430
- 해당 포트에서 정상 구동되었는지 브라우저로 확인
방법 2 : Docker Image 빌드를 위한 파일인 Dockerfile로 만들기
(1) Dockerfile 공식 문서를 통해 Dockerfile(as like 이미지 파일의 설명서)을 만들고 Dockerfile대로 이미지 build하는 방법 확인 가능
- RUN, CMD, ENTRYPOINT 명령어 헷갈리니 참고할 것
- 해당 서버 파일이 있는 위치에 Dockerfile 만들기 (파일명 Dockerfile)
$ cat Dockerfile
FROM httpd:2.4
WORKDIR /usr/local/apache2
COPY ./ /usr/local/apache2/htdocs/
# 배포시 사용하는 conf 파일
# COPY ./httpd.conf /usr/local/apache2/conf/
(2) 도커 이미지 파일 생성
docker build --tag 이미지명:tag .
- 지정한 경로에 있는 Dockerfile을 찾아 빌드하므로, "."가 명령어에 꼭 포함되어야 함 (실행 위치 중요)
$ docker build --tag my_pacman:2.0 .
[+] Building 7.2s (8/8) FINISHED
=> [internal] load build definition from Dockerfile 0.4s
=> => transferring dockerfile: 198B 0.0s
=> [internal] load .dockerignore 0.3s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/httpd:2.4 2.9s
=> [1/3] FROM docker.io/library/httpd:2.4@sha256:4055b18d92fd006f74d4a2aac172a371dc9a750eaa78000756dee55a9beb4625 0.7s
=> [internal] load build context 0.8s
=> => transferring context: 17.21MB 0.3s
=> [2/3] WORKDIR /usr/local/apache2 1.5s
=> [3/3] COPY ./ /usr/local/apache2/htdocs/ 1.4s
=> exporting to image 0.3s
=> => exporting layers 0.3s
=> => writing image sha256:095dd5beb2490279a687327ecbc90e18b7ed610a6e17b7c762d18abd5cf9ac1e 0.0s
=> => naming to docker.io/library/my_pacman:2.0
(2) 생성된 이미지를 이용해 901포트에서 웹 서버 구동 및 확인
$ docker run --name my_web_image -p 901:80 my_pacman:2.0
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
[Tue Apr 11 01:25:45.004516 2023] [mpm_event:notice] [pid 1:tid 140144282860864] AH00489: Apache/2.4.57 (Unix) configured -- resuming normal operations
[Tue Apr 11 01:25:45.004846 2023] [core:notice] [pid 1:tid 140144282860864] AH00094: Command line: 'httpd -D FOREGROUND'
# References
# 도커 data 영역 디렉토리 : 컨테이너의 물리적 이미지를 저장 컨테이너가 구동되었을 때 이미지 레이어 외의 컨테이너 레이어 정보를 저장하는 영역
root@devops:/var/lib/docker# pwd
/var/lib/docker
root@devops:/var/lib/docker# ll
합계 52
drwx--x--- 12 root root 4096 4월 11 09:06 ./
drwxr-xr-x 74 root root 4096 3월 30 11:02 ../
drwx--x--x 4 root root 4096 3월 22 10:36 buildkit/
drwx--x--- 3 root root 4096 4월 11 09:25 containers/
-rw------- 1 root root 36 3월 22 10:36 engine-id
drwx------ 3 root root 4096 3월 22 10:36 image/
drwxr-x--- 3 root root 4096 3월 22 10:36 network/
drwx--x--- 10 root root 4096 4월 11 09:25 overlay2/
drwx------ 4 root root 4096 3월 22 10:36 plugins/
drwx------ 2 root root 4096 4월 11 09:06 runtimes/
drwx------ 2 root root 4096 3월 22 10:36 swarm/
drwx------ 2 root root 4096 4월 11 09:23 tmp/
drwx-----x 2 root root 4096 4월 11 09:06 volumes/
'devops bootcamp 4 > 클라우드 서비스 운영' 카테고리의 다른 글
[Docker] 04. 애플리케이션 컨테이너화 (1) | 2023.04.13 |
---|---|
[Docker] 03. Docker Image 다루기 (0) | 2023.04.12 |
[Docker] 01. 왜 Docker인가? (0) | 2023.04.11 |
[Docker] 00. Before You Learn (0) | 2023.04.11 |
[YAML] 01. YAML과 JSON (0) | 2023.04.11 |