KILLERCODA - CKAD - Build and run a Container 오답노트

hyereen·2025년 2월 1일

Kubernetes

목록 보기
41/53

1
Create a new file /root/Dockerfile to build a container image from. It should:
use bash as base
run ping killercoda.com
Build the image and tag it as pinger .
Run the image (create a container) named my-ping .
You can use docker or podman for this scenario. Just stick to your choice throughout all steps.

정답

  • Dockerfile
controlplane $ cat Dockerfile 
FROM bash

CMD ["ping", "killercoda.com"]
  • docker 이용
docker build -t pinger .
docker images
docker run --name my-ping pinger

참고

  • 컨테이너 지우기 (강제로)
docker rm -f my-ping

2
Tag the image, which is currently tagged as pinger , also as local-registry:5000/pinger .
Then push the image into the local registry.

정답

controlplane $ docker tag pinger local-registry:5000/pinger
controlplane $ docker images
REPOSITORY                   TAG       IMAGE ID       CREATED          SIZE
pinger                       latest    25b4c35b04a9   21 minutes ago   14.5MB
local-registry:5000/pinger   latest    25b4c35b04a9   21 minutes ago   14.5MB
<none>                       <none>    131d63b0f61a   25 minutes ago   14.5MB
bash                         latest    2a658e2e2bab   7 weeks ago      14.5MB
controlplane $ docker push local-registry:5000/pinger
Using default tag: latest
The push refers to repository [local-registry:5000/pinger]
7ec30c42b129: Pushed 
8dba5e843521: Pushed 
a0904247e36a: Pushed 
latest: digest: sha256:033c1472c1514fa88fd1650adcfedcbe3e01c33826d98544af73e250b3febfad size: 946

3
Without specifying a :tag , the default :latest will be used. Now we want to use tag :v1 instead.
Tag the image, which is currently tagged as pinger , also as pinger:v1 and local-registry:5000/pinger:v1 .
Then push the image into the local registry.

정답

docker tag pinger pinger:v1
docker tag pinger local-registry:5000/pinger:v1
controlplane $ docker images
REPOSITORY                   TAG       IMAGE ID       CREATED          SIZE
pinger                       latest    25b4c35b04a9   35 minutes ago   14.5MB
pinger                       v1        25b4c35b04a9   35 minutes ago   14.5MB
local-registry:5000/pinger   latest    25b4c35b04a9   35 minutes ago   14.5MB
local-registry:5000/pinger   v1        25b4c35b04a9   35 minutes ago   14.5MB
<none>                       <none>    131d63b0f61a   38 minutes ago   14.5MB
bash                         latest    2a658e2e2bab   7 weeks ago      14.5MB
docker push local-registry:5000/pinger:v1

0개의 댓글