3.3.컨테이너 이미지 빌드하기

docker image build 명령을 사용해 Dockerfile 스크립트로 이미지를 빌드하라

docker image build --tag web-ping .
  • .: Dockerfile 및 이미지에 포함시킬 파일이 위치한 경로. 도커에서는 이 디렉터리를 컨텍스트라고 한다.
001)  docker image build --tag web-ping .
002) [+] Building 3.5s (9/9) FINISHED
003)  => [internal] load .dockerignore                                                                                                                          0.0s
004)  => => transferring context: 2B                                                                                                                            0.0s
005)  => [internal] load build definition from Dockerfile                                                                                                       0.0s
006)  => => transferring dockerfile: 191B                                                                                                                       0.0s
007)  => [internal] load metadata for docker.io/diamol/node:latest                                                                                              3.4s
008)  => [auth] diamol/node:pull token for registry-1.docker.io                                                                                                 0.0s
009)  => [1/3] FROM docker.io/diamol/node@sha256:dfee522acebdfdd9964aa9c88ebebd03a20b6dd573908347be3ebf52ac4879c8                                               0.0s
010)  => => resolve docker.io/diamol/node@sha256:dfee522acebdfdd9964aa9c88ebebd03a20b6dd573908347be3ebf52ac4879c8                                               0.0s
011)  => => sha256:6467efe6481aace0c317f144079c1a321b91375a828dbdb59b363a2aef78b33b 1.16kB / 1.16kB                                                             0.0s
012)  => => sha256:8e0eeb0a11b3a91cc1d91b5ef637edd153a64a3792e08a3f8d0702ec4f01a9e7 5.66kB / 5.66kB                                                             0.0s
013)  => => sha256:dfee522acebdfdd9964aa9c88ebebd03a20b6dd573908347be3ebf52ac4879c8 1.41kB / 1.41kB                                                             0.0s
014)  => [internal] load build context                                                                                                                          0.0s
015)  => => transferring context: 881B                                                                                                                          0.0s
016)  => [2/3] WORKDIR /web-ping                                                                                                                                0.0s
017)  => [3/3] COPY app.js .                                                                                                                                    0.0s
018)  => exporting to image                                                                                                                                     0.0s
019)  => => exporting layers                                                                                                                                    0.0s
020)  => => writing image sha256:79e5b536f935a9d1e8fc5805486f6c9a1a8b8bb1ac41600bd479aacadf1d6789                                                               0.0s
021)  => => naming to docker.io/library/web-ping
022) 
023)  docker image ls 'w*'
024) REPOSITORY   TAG       IMAGE ID       CREATED              SIZE
025) web-ping     latest    79e5b536f935   About a minute ago   75.5MB

새로 빌드한 이미지로부터 컨테이너를 실행해 도커 웹사이트에 5초마다 요청을 보내자

001)  docker container run -e TARGET=docker.com -e INTERVAL=5000 web-ping
002) ** web-ping ** Pinging: docker.com; method: HEAD; 5000ms intervals
003) Making request number: 1; at 1686888744193
004) Got response status: 403 at 1686888744289; duration: 96ms
005) Making request number: 2; at 1686888749195
006) Got response status: 403 at 1686888749232; duration: 37ms
007) Making request number: 3; at 1686888754199
008) Got response status: 403 at 1686888754248; duration: 49ms

links

social