先放个链接,万一有人关注呢
优质文章推荐
↓ ↓ ↓ ↓ ↓
Docker镜像通常保存在docker Hub,docker Hub是目前最大的Docker镜像公有仓库,由Docker官方人员进行维护,其中的镜像可供所有用户下载使用。在生产环境中,通常公司会构建一些符合公司业务需求的镜像,却又因为商业机密而不得上传至docker Hub,只供公司内部人员使用。此时就需要在内网搭建一个Docker私有仓库,来存储公司内部的镜像,并且可以不受网络限制,快速地拉取或上传镜像。镜像为Docker容器的运行基础,容器是镜像的具体运行实例,镜像仓库为镜像提供了可靠的存储空间,镜像可以从公有或私有仓库拉取。

~]# docker pull registryUsing default tag: latestlatest: Pulling from library/registryc87736221ed0: Pull complete1cc8e0bb44df: Pull complete54d33bcb37f5: Pull completee8afc091c171: Pull completeb4541f6d3db6: Pull completeDigest: sha256:db8e07b1da92e1774458798a018512d71d869887d80b13cf126acda20122e41eStatus: Downloaded newer image for registry:latest~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEregistry latest f32a97de94e1 5 weeks ago 25.8MB
[root@Docker-1 ~]# docker run -it -d -p 5000:5000 \--restart=always \--name registry registry84e48495b8a18b151e128b8698cf776a5e9aab40c57ed15bb055835a407ef1db
[]Using default tag: latestlatest: Pulling from library/busyboxfc1a6b909f82: Pull completeDigest: sha256:577311505bc76f39349a2d389d32c7967ca478de918104126c10aa0eb7f101fdStatus: Downloaded newer image for busybox:latest[][]Error response from daemon: Get https://192.168.56.146:5000/v2/: http: server gave HTTP response to HTTPS client
[root@Docker-1 ~]# cat /usr/lib/systemd/system/Docker.service......[Service]Type=notify# the default is not to use systemd for cgroups because the delegate issues still# exists and systemd currently does not support the cgroup feature set required# for containers run by DockerExecStart=/usr/bin/Dockerd --insecure-registry 192.168.56.146:5000ExecReload=/bin/kill -s HUP $MAINPIDTimeoutSec=0RestartSec=2Restart=always......#修改配置文件,如上代码所示:在ExecStart=/usr/bin/Dockerd后添加--insecure-registry IP:5000代码段[root@Docker-1 ~]# systemctl daemon-reload[root@Docker-1 ~]# systemctl restart Docker
[root@Docker-1 ~]# docker push 192.168.56.146:5000/busybox:latestThe push refers to repository [192.168.56.146:5000/busybox]0b97b1c81a32: Pushedlatest: digest: sha256:f79f7a10302c402c052973e3fa42be0344ae6453245669783a9e16da3d56d5b4 size: 527
[root@Docker-1 ~]# curl -X GET http://192.168.56.146:5000/v2/_catalog{"repositories":["busybox"]}#使用curl工具查看,可以看到仓库中有一个busybox镜像[root@Docker-1 ~]# docker rmi busyboxUntagged: busybox:latestUntagged: busybox@sha256:577311505bc76f39349a2d389d32c7967ca478de918104126c10aa0eb7f101fd[root@Docker-1 ~]# docker rmi 192.168.56.146:5000/busyboxUntagged: 192.168.56.146:5000/busybox:latestUntagged: 192.168.56.146:5000/busybox@sha256:f79f7a10302c402c052973e3fa42be0344ae6453245669783a9e16da3d56d5b4Deleted: sha256:af2f74c517aac1d26793a6ed05ff45b299a037e1a9eefeae5eacda133e70a825Deleted: sha256:0b97b1c81a3200e9eeb87f17a5d25a50791a16fa08fc41eb94ad15f26516ccea[root@Docker-1 ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEregistry latest f32a97de94e1 5 weeks ago 25.8MB#删除本地的busybox镜像,可以看到本地已经没有busybox镜像,下面尝试从私有仓库中拉取busybox镜像[root@Docker-1 ~]# docker pull 192.168.56.146:5000/busyboxUsing default tag: latestlatest: Pulling from busyboxfc1a6b909f82: Pull completeDigest: sha256:f79f7a10302c402c052973e3fa42be0344ae6453245669783a9e16da3d56d5b4Status: Downloaded newer image for 192.168.56.146:5000/busybox:latest[root@Docker-1 ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZE192.168.56.146:5000/busybox latest af2f74c517aa 13 days ago 1.2MBregistry latest f32a97de94e1 5 weeks ago 25.8MB
[]Using default tag: latestlatest: Pulling from busyboxfc1a6b909f82: Pull completeDigest: sha256:f79f7a10302c402c052973e3fa42be0344ae6453245669783a9e16da3d56d5b4Status: Downloaded newer image for 192.168.56.146:5000/busybox:latest[]REPOSITORY TAG IMAGE ID CREATED SIZE192.168.56.146:5000/busybox latest af2f74c517aa 13 days ago 1.2MB
来不及解释了,快上车!(进群看公告)

欢迎新的小伙伴加入!在这里,我们鼓励大家积极参与群内讨论和交流,分享自己的见解和经验,一起学习和成长。同时,也欢迎大家提出问题和建议,让我们不断改进和完善这个平台。
↓↓↓ 点个在看,你最好看!