카타코더 Docker - Building Container Images

Jmnote (토론 | 기여)님의 2019년 3월 23일 (토) 19:24 판 (→‎개요)

1 개요

Katacoda - Docker - Building Container Images
카타코더 Docker
# 🔗 제목
카타코더 Docker/1 e
🡵 카타코더 Docker - Deploying Your First Docker Container
🡵 카타코더 Docker - Deploy Static HTML Website as Container
🡵 카타코더 Docker - Building Container Images
🡵 카타코더 Docker - Dockerizing Node.js
🡵 카타코더 Docker - Optimise Builds With Docker OnBuild
🡵 카타코더 Docker - Ignoring Files During Build
🡵 카타코더 Docker - Create Data Containers
🡵 카타코더 Docker - Creating Networks Between Containers using Links
🡵 카타코더 Docker - Creating Networks Between Containers using Networks
🡵 카타코더 Docker - Persisting Data Using Volumes

2 Dockerfile 작성

$ ll
total 16
drwxr-xr-x 1 scrapbook scrapbook 4096 Mar 22 15:20 ./
drwxr-xr-x 1 scrapbook scrapbook 4096 Jun  8  2018 ../
-rw-r--r-- 1 root      root       121 Mar 22 15:20 Dockerfile
-rw-r--r-- 1 root      root        21 Mar 22 15:20 index.html
$ cat index.html
<h1>Hello World</h1>
Dockerfile
FROM nginx:1.11-alpine
COPY index.html /usr/share/nginx/html/index.html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

3 컨테이드 빌드

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
$ docker build -t nginx .
Sending build context to Docker daemon  3.072kB
Step 1/4 : FROM nginx:1.11-alpine
1.11-alpine: Pulling from library/nginx
709515475419: Pull complete
4b21d71b440a: Pull complete
c92260fe6357: Pull complete
ed383a1b82df: Pull complete
Digest: sha256:5aadb68304a38a8e2719605e4e180413f390cd6647602bee9bdedd59753c3590
Status: Downloaded newer image for nginx:1.11-alpine
 ---> bedece1f06cc
Step 2/4 : COPY index.html /usr/share/nginx/html/index.html
 ---> ff82266f8a3c
Step 3/4 : EXPOSE 80
 ---> Running in 75539b6235b5
Removing intermediate container 75539b6235b5
 ---> b06ce6726b2a
Step 4/4 : CMD ["nginx", "-g", "daemon off;"]
 ---> Running in df877b3d066b
Removing intermediate container df877b3d066b
 ---> a2272ce5f857
Successfully built a2272ce5f857
Successfully tagged nginx:latest
$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              a2272ce5f857        7 seconds ago       54.3MB
nginx               1.11-alpine         bedece1f06cc        23 months ago       54.3MB

4 이미지 실행하기

$ docker run -d -p 80:80 nginx
45afb3ea6530661117140229e1959133552d8d31c45cfa72d27b957c6444d0a6
$ curl -i http://docker
HTTP/1.1 200 OK
Server: nginx/1.11.13
Date: Fri, 22 Mar 2019 15:08:40 GMT
Content-Type: text/html
Content-Length: 21
Last-Modified: Fri, 22 Mar 2019 14:57:48 GMT
Connection: keep-alive
ETag: "5c94f7ec-15"
Accept-Ranges: bytes

<h1>Hello World</h1>
$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS      PORTS                         NAMES
45afb3ea6530        nginx               "nginx -g 'daemon of…"   47 seconds ago      Up 45 seconds      0.0.0.0:80->80/tcp, 443/tcp   boring_kare

5 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}