미션 #5. 컨테이너 이미지 사례 실습
6개월 전


빌드
docker build -t test/hello:1.0.0 .
[+] Building 12.3s (8/8) FINISHED docker:desktop-linux
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 97B 0.0s
=> [internal] load metadata for docker.io/library/node:slim 2.3s
=> [auth] library/node:pull token for registry-1.docker.io 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 215B 0.0s
=> [1/2] FROM docker.io/library/node:slim@sha256:b30c143a092c7dced8e17ad67a8783c03234d4844ee 9.6s
=> => resolve docker.io/library/node:slim@sha256:b30c143a092c7dced8e17ad67a8783c03234d4844ee 0.0s
=> => sha256:34ef2a75627f6089e01995bfd3b3786509bbdc7cfb4dbc804b642e195340d 28.08MB / 28.08MB 7.7s
=> => sha256:00b6bc59183634774862a1f5d9fa777966ffdd8b4edd6fe07006671358dfc24 3.31kB / 3.31kB 0.7s
=> => sha256:7293ae927b976710c33b54ae3957471f36b9e1150408853c3dfbd7baff3f5 50.52MB / 50.52MB 8.7s
=> => sha256:b30c143a092c7dced8e17ad67a8783c03234d4844ee84c39090c9780491aaf8 5.20kB / 5.20kB 0.0s
=> => sha256:af442a7998c3f3a985309cfa7b709ea8d3f1911ea19a598f1f1a2e158273c73 1.93kB / 1.93kB 0.0s
=> => sha256:85878ac12a824d35ede83635c5aa0a6b4c83fe0b8fa5fb125e1fc839a5af01a 6.59kB / 6.59kB 0.0s
=> => sha256:148b7926ba2143f7dbd1efaab45bd08b5fde13f01510d1319ee7cd0aa781f8d 1.71MB / 1.71MB 1.5s
=> => sha256:0a5428d7ed1bdde6d0638d39b519fcd3307eb60e70ba9f220d1066b39a71de93 447B / 447B 1.9s
=> => extracting sha256:34ef2a75627f6089e01995bfd3b3786509bbdc7cfb4dbc804b642e195340dbc9 0.8s
=> => extracting sha256:00b6bc59183634774862a1f5d9fa777966ffdd8b4edd6fe07006671358dfc249 0.0s
=> => extracting sha256:7293ae927b976710c33b54ae3957471f36b9e1150408853c3dfbd7baff3f59d1 0.8s
=> => extracting sha256:148b7926ba2143f7dbd1efaab45bd08b5fde13f01510d1319ee7cd0aa781f8d0 0.0s
=> => extracting sha256:0a5428d7ed1bdde6d0638d39b519fcd3307eb60e70ba9f220d1066b39a71de93 0.0s
=> [2/2] COPY hello.js . 0.2s
=> exporting to image 0.1s
=> => exporting layers 0.0s
=> => writing image sha256:7d635123c7017af009e6818217e513383410b544c4f5aad555221a02b1b4e1d7 0.0s
=> => naming to docker.io/hello:1.0.0 0.0s
이미지 조회
docker image list
REPOSITORY TAG IMAGE ID CREATED SIZE
/hello 1.0.0 7d635123c701 2 minutes ago 249MB
jenkins/jenkins lts-jdk17 eb3da18f5f0b 8 months ago 499MB
kindest/node <none> 1cf551538f7d 16 months ago 96
이미지 태그 변경
docker login -u hamtaro
Password:
Login Succeeded
이미지 푸쉬
docker push /hello:1.0.0
The push refers to repository [docker.io/hello]
ab1c299e0236: Pushed
a04dc377afe1: Mounted from library/node
1b2a793e9797: Mounted from library/node
0fa9dab4f369: Mounted from library/node
abb3903f11f9: Mounted from library/node
6edfb9bfff29: Mounted from library/node
1.0.0: digest: sha256:603e375fb7f34d7f376f13c8193864b914742d186371f60842c6cfa99132bd9a size: 1574
이미지 삭제
docker rmi -f 7d635123701
Untagged: /hello:1.0.0
Untagged: /hello:2.0.0
Untagged: /hello@sha256:603e375fb7f34d7f376f13c8193864b914742d186371f6c6cfa99132bd9a
Deleted: sha256:7d635123c7017af009e6818217e5133844c4f5aad555221a02b1b4e1d7
이미지 다운로드
docker pull /hello:1.0.0
1.0.0: Pulling from /hello
34ef2a75627f: Already exists
00b6bc591836: Already exists
7293ae927b97: Already exists
148b7926ba21: Already exists
0a5428d7ed1b: Already exists
d03369722173: Already exists
Digest: sha256:603e375fb7f34d7f376f13c81186371f60842c6cfa99132bd9a
Status: Downloaded newer image for /hello:1.0.0
docker.io/hello:1.0.0
이미지 파일 변환
docker save -o file.tar 7d635123c701
ls
Dockerfile file.tar hello.js
docker load -i file.tar
Loaded image ID: 7d635123c7017af009e6818217e513383410b544c4f5aad555221a02b1b4e1d7
containerd
[root@k8s-master ~]# ctr ns list
NAME LABELS
k8s.io
[root@k8s-master ~]# ctr -n k8s.io image list
REF TYPE DIGEST SIZE PLATFORMS LABELS
docker.io/1pro/api-tester:v1.0.0 application/vnd.oci.image.index.v1+json sha256:6b38dd347b66c7f14c393280a040831a72b4a93fd5beddc011ee852c26f35058 247.8 MiB linux/amd64,linux/arm64,unknown/unknown io.cri-containerd.image=managed
docker.io/1pro/api-tester:v2.0.0
...
[root@k8s-master ~]# ctr images pull docker.io/sd0241/hello:1.0.0
docker.io/sd0241/hello:1.0.0: resolved |++++++++++++++++++++++++++++++++++++++|
manifest-sha256:603e375fb7f34d7f376f13c8193864b914742d186371f60842c6cfa99132bd9a: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:00b6bc59183634774862a1f5d9fa777966ffdd8b4edd6fe07006671358dfc249: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:d0336972217335effba593a6a5da5d1732e7c19c5953843cffb2e71d279196e7: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:148b7926ba2143f7dbd1efaab45bd08b5fde13f01510d1319ee7cd0aa781f8d0: done |++++++++++++++++++++++++++++++++++++++|
config-sha256:7d635123c7017af009e6818217e513383410b544c4f5aad555221a02b1b4e1d7: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:0a5428d7ed1bdde6d0638d39b519fcd3307eb60e70ba9f220d1066b39a71de93: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:7293ae927b976710c33b54ae3957471f36b9e1150408853c3dfbd7baff3f59d1: done |++++++++++++++++++++++++++++++++++++++|
layer-sha256:34ef2a75627f6089e01995bfd3b3786509bbdc7cfb4dbc804b642e195340dbc9: done |++++++++++++++++++++++++++++++++++++++|
elapsed: 12.1s total: 76.6 M (6.3 MiB/s)
unpacking linux/arm64/v8 sha256:603e375fb7f34d7f376f13c8193864b914742d186371f60842c6cfa99132bd9a...
done: 1.269243327s
[root@k8s-master ~]# ctr ns list
NAME LABELS
default
k8s.io
[root@k8s-master ~]# ctr images list
REF TYPE DIGEST SIZE PLATFORMS LABELS
docker.io/sd0241/hello:1.0.0 application/vnd.docker.distribution.manifest.v2+json sha256:603e375fb7f34d7f376f13c8193864b914742d186371f60842c6cfa99132bd9a 76.6 MiB linux/arm64 -
[root@k8s-master ~]# ctr images tag docker.io/sd0241/hello:1.0.0 docker.io/sd0241/hello:2.0.0
docker.io/sd0241/hello:2.0.0
[root@k8s-master ~]# ctr images list
REF TYPE DIGEST SIZE PLATFORMS LABELS
docker.io/sd0241/hello:1.0.0 application/vnd.docker.distribution.manifest.v2+json sha256:603e375fb7f34d7f376f13c8193864b914742d186371f60842c6cfa99132bd9a 76.6 MiB linux/arm64 -
docker.io/sd0241/hello:2.0.0 application/vnd.docker.distribution.manifest.v2+json sha256:603e375fb7f34d7f376f13c8193864b914742d186371f60842c6cfa99132bd9a 76.6 MiB linux/arm64 -
[root@k8s-master ~]# ctr images tag docker.io/sd0241/hello:1.0.0 docker.io/sd0241/hello:2.0.0
docker.io/sd0241/hello:2.0.0
[root@k8s-master ~]# ctr images list
REF TYPE DIGEST SIZE PLATFORMS LABELS
docker.io/sd0241/hello:1.0.0 application/vnd.docker.distribution.manifest.v2+json sha256:603e375fb7f34d7f376f13c8193864b914742d186371f60842c6cfa99132bd9a 76.6 MiB linux/arm64 -
docker.io/sd0241/hello:2.0.0 application/vnd.docker.distribution.manifest.v2+json sha256:603e375fb7f34d7f376f13c8193864b914742d186371f60842c6cfa99132bd9a 76.6 MiB linux/arm64 -
[root@k8s-master ~]# ctr image push docker.io/sd0241/hello:2.0.0 --user sd0241
Password:
manifest-sha256:603e375fb7f34d7f376f13c8193864b914742d186371f60842c6cfa99132bd9a: done |++++++++++++++++++++++++++++++++++++++|
config-sha256:7d635123c7017af009e6818217e513383410b544c4f5aad555221a02b1b4e1d7: done |++++++++++++++++++++++++++++++++++++++|
elapsed: 3.0 s
댓글을 작성해보세요.