本地私服安装
docker pull registry
安装示例:
➜ ~ docker pull registry
Using default tag: latest
latest: Pulling from library/registry
79e9f2f55bf5: Pull complete
0d96da54f60b: Pull complete
5b27040df4a2: Pull complete
e2ead8259a04: Pull complete
3790aef225b9: Pull complete
Digest: sha256:169211e20e2f2d5d115674681eb79d21a217b296b43374b8e39f97fcf866b375
Status: Downloaded newer image for registry:latest
docker.io/library/registry:latest
启动本地私服
docker run -it -p5000:5000 -v /Users/huzd/Downloads/registry/:/tmp/registry --privileged=true registry
➜ ~ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.cn-qingdao.aliyuncs.com/huzd/test 1.0.0 753e19c60999 3 hours ago 178MB
huzd/iredis 1.1.1 b292881e118d 28 hours ago 109MB
docker/disk-usage-extension 0.2.4 8046bf511714 2 days ago 2.97MB
kartoza/geoserver 2.20.4 2c8bec02cf4e 2 months ago 1.43GB
nginx latest 605c77e624dd 5 months ago 141MB
redis latest 7614ae9453d1 5 months ago 113MB
registry latest b8604a3fe854 7 months ago 26.2MB
ubuntu latest ba6acccedd29 8 months ago 72.8MB
hello-world latest feb5d9fea6a5 8 months ago 13.3kB
➜ ~ docker run -it -p5000:5000 -v /Users/huzd/Downloads/registry/:/tmp/registry --privileged=true registry #命令
WARN[0000] No HTTP secret provided - generated random secret. This may cause problems with uploads if multiple registries are behind a load-balancer. To provide a shared secret, fill in http.secret in the configuration file or set the REGISTRY_HTTP_SECRET environment variable. go.version=go1.11.2 instance.id=908dc080-5fcb-4adf-837a-7aeccfc3254a service=registry version=v2.7.1
INFO[0000] redis not configured go.version=go1.11.2 instance.id=908dc080-5fcb-4adf-837a-7aeccfc3254a service=registry version=v2.7.1
INFO[0000] Starting upload purge in 5m0s go.version=go1.11.2 instance.id=908dc080-5fcb-4adf-837a-7aeccfc3254a service=registry version=v2.7.1
INFO[0000] using inmemory blob descriptor cache go.version=go1.11.2 instance.id=908dc080-5fcb-4adf-837a-7aeccfc3254a service=registry version=v2.7.1
INFO[0000] listening on [::]:5000 go.version=go1.11.2 instance.id=908dc080-5fcb-4adf-837a-7aeccfc3254a service=registry version=v2.7.1
推送镜像到私服
➜ ~ docker ps #1 查询后台正在运行的容器。确认我们的私服正在运行。
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
11b88904b686 registry "/entrypoint.sh /etc…" 58 seconds ago Up 56 seconds 0.0.0.0:5000->5000/tcp naughty_roentgen
➜ ~ curl -XGET http://localhost:5000/v2/_catalog #2 通过一个web接口查看私服仓库包含的镜像仓库
{"repositories":[]}
➜ ~ docker images #3 查看我们的镜像仓库,寻找一个目标作为测试。镜像打标
REPOSITORY TAG IMAGE ID CREATED SIZE
registry.cn-qingdao.aliyuncs.com/huzd/test 1.0.0 753e19c60999 3 hours ago 178MB
huzd/iredis 1.1.1 b292881e118d 28 hours ago 109MB
docker/disk-usage-extension 0.2.4 8046bf511714 2 days ago 2.97MB
kartoza/geoserver 2.20.4 2c8bec02cf4e 2 months ago 1.43GB
nginx latest 605c77e624dd 5 months ago 141MB
redis latest 7614ae9453d1 5 months ago 113MB
registry latest b8604a3fe854 7 months ago 26.2MB
ubuntu latest ba6acccedd29 8 months ago 72.8MB
hello-world latest feb5d9fea6a5 8 months ago 13.3kB
➜ ~ docker tag 753e19c60999 localhost:5000/test:1.0.0 #4 将之前练习的进行文件打标
➜ ~ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost:5000/test 1.0.0 753e19c60999 3 hours ago 178MB
registry.cn-qingdao.aliyuncs.com/huzd/test 1.0.0 753e19c60999 3 hours ago 178MB
huzd/iredis 1.1.1 b292881e118d 28 hours ago 109MB
docker/disk-usage-extension 0.2.4 8046bf511714 2 days ago 2.97MB
kartoza/geoserver 2.20.4 2c8bec02cf4e 2 months ago 1.43GB
nginx latest 605c77e624dd 5 months ago 141MB
redis latest 7614ae9453d1 5 months ago 113MB
registry latest b8604a3fe854 7 months ago 26.2MB
ubuntu latest ba6acccedd29 8 months ago 72.8MB
hello-world latest feb5d9fea6a5 8 months ago 13.3kB
➜ ~ docker push localhost:5000/test:1.0.0 #5 将本地镜像推送到私有仓库
The push refers to repository [localhost:5000/test]
9df8cd7c0733: Pushed
9f54eef41275: Pushed
1.0.0: digest: sha256:f6aa57103c935fad34aa1fecfb738be72ab7217da711179f9264c1a4501b553c size: 741
➜ ~ curl -XGET http://localhost:5000/v2/_catalog #6 请求私有仓库的web接口,确认是否推送成功。
{"repositories":["test"]}
➜ ~
下载私有库镜像到本地
➜ ~ docker pull localhost:5000/test:1.0.0
1.0.0: Pulling from test
7b1a6ab2e44d: Already exists
5579862b1fa8: Already exists
Digest: sha256:f6aa57103c935fad34aa1fecfb738be72ab7217da711179f9264c1a4501b553c
Status: Downloaded newer image for localhost:5000/test:1.0.0
localhost:5000/test:1.0.0
➜ ~ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost:5000/test 1.0.0 753e19c60999 4 hours ago 178MB
huzd/iredis 1.1.1 b292881e118d 28 hours ago 109MB
docker/disk-usage-extension 0.2.4 8046bf511714 2 days ago 2.97MB
kartoza/geoserver 2.20.4 2c8bec02cf4e 2 months ago 1.43GB
nginx latest 605c77e624dd 5 months ago 141MB
redis latest 7614ae9453d1 5 months ago 113MB
registry latest b8604a3fe854 7 months ago 26.2MB
ubuntu latest ba6acccedd29 8 months ago 72.8MB
hello-world latest feb5d9fea6a5 8 months ago 13.3kB
本文由 huzd 创作,采用 知识共享署名4.0 国际许可协议进行许可本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名最后编辑时间
为:
2022/06/30 22:32