Software

推送至私有 Registry

上一章已經建立好了私有的 Registry 這一章則要來實作建立 image 然後推送

1. 建立一個 image

#docker build -t web:1.0 .

參數說明:
buile : 利用 Dockerfile 建立一個 image
-t : 針對這個 image 命名,前面是名字後面是 Tag
. : Dockerfile 的位置

2. 標記已建立的 image

#docker tag web:1.0 127.0.0.1:5000/test:1.0

#docker images

REPOSITORY            TAG       IMAGE ID       CREATED        SIZE
127.0.0.1:5000/test   1.0       c805ef25f0f3   20 hours ago   489MB
web                   1.0       c805ef25f0f3   20 hours ago   489MB

完成標記後就會多出一個image的連結

3. 上傳已標記的 image

#docker push 127.0.0.1:5000/test:1.0

The push refers to repository [127.0.0.1:5000/test]
1d5d2e5962a7: Pushed
703a038a27f4: Pushed
e4f1b55f3f8a: Pushed
50b41e84c348: Pushed
c29cc6c693ff: Pushed
dc4f2875405c: Pushed
1.0: digest: sha256:c2788d779a78bd8a37b2e0861fd7d336a332ec41d82269c3dbef0f28df38b0d7 size: 1570

4. 確認已上傳的 image
http://127.0.0.1:5000/v2/_catalog
使用網址可以確認以上傳的 image

{
repositories: [
"test"
]
}

如果要拉下來就帶上位置就好了

#docker pull 127.0.0.1:5000/test:1.0

1.0: Pulling from test
9b99af5931b3: Already exists
58de94a7239b: Already exists
e5e05eab6a87: Already exists
9af9a9ff78c6: Already exists
d2ac40e6e58d: Already exists
00a2f453d397: Already exists
Digest: sha256:c2788d779a78bd8a37b2e0861fd7d336a332ec41d82269c3dbef0f28df38b0d7
Status: Downloaded newer image for 127.0.0.1:5000/test:1.0
127.0.0.1:5000/test:1.0