對於公司內的 Docker 使用,當然就不能把一堆程式碼都擺在外頭的 dockerhub 來管理,所幸的 Docker Registry 也可以透過 Docker 快速建立,並且把資料儲存那段跟指定的機器儲存結合,瞬間立馬建置完畢:
Docker Registry - docs.docker.com/registry/
操作:
% docker run -d -p 5000:5000 -v /tmp/registry-stoarge:/var/lib/registry --name registry registry:2Unable to find image 'registry:2' locally2: Pulling from library/registry...: Pull complete% docker container listCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES1ab332dd4bb5 registry:2 "/entrypoint.sh /etc…" 21 seconds ago Up 20 seconds 0.0.0.0:5000->5000/tcp registry
將 image 發佈到指定的 Docker Registry server:
% docker image listREPOSITORY TAG IMAGE ID CREATED SIZEmy/test 1.0.0 9b400be021d8 25 hours ago 457MBregistry 2 0030ba3d620c 5 weeks ago 24.1MB% docker tag my/test:1.0.0 localhost:5000/my/test% docker push localhost:5000/my/testUsing default tag: latestThe push refers to repository [localhost:5000/my/test]............: Pushed............: Pushed............: Pushedlatest: digest: sha256:...........size: ...
列出指定的 Docker Registry server 上的 image list:
% curl localhost:5000/v2/_catalog{"repositories":["my/test"]}
列出指定的 Docker Registry server 上的 image 上的 tag list:
% curl localhost:5000/v2/my/test/tags/list{"name":"my/test","tags":["latest"]}
查看一下 /tmp/registry-stoarge 內已經儲存的資料結構:
% tree -L 7 /tmp/registry-stoarge/tmp/registry-stoarge└── docker└── registry└── v2├── blobs│ └── sha256│ ├── ...│ │ └── ...│ └── ...│ └── ...└── repositories└── my└── test├── _layers├── _manifests└── _uploads30 directories, 0 files
最後,使用 Docker Registry server 上的 image 做事:
% docker run -it localhost:5000/my/testroot@.....:/# ls
沒有留言:
張貼留言