https://hub.docker.com,进入后点击sign up注册docker账号
# docker login https://hub.docker.com
# docker search centos
参考文档:官方镜像加速
ip | 角色 |
192.168.217.128 | 本地仓库 |
192.168.217.130 | docker客户端 |
[root@docker ~]# docker run -d -p 5000:5000 registry:2
[root@docker ~]# docker run -d -p 5000:5000 -v /registry:/var/lib/registry registry:2
vim /etc/docker/daemon.json,
添加下面的内容: "insecure-registries":["192.168.217.128:5000"], 再重启docker 服务
打开镜像的存储目录,如有-V操作打开挂载目录也可以,删除镜像文件夹
docker exec <容器名> rm -rf /var/lib/registry/docker/registry/v2/repositories/<镜像名>
docker exec registry bin/registry garbage-collect /etc/docker/registry/config.yml
Harbor:是一个用于存储Docker镜像的企业级Registry服务。
Registry是Dcoker官方的一个私有仓库镜像,可以将本地的镜像打标签进行标记然后push到Registry私有仓库中。企业可以根据自己的需求,使用Dokcerfile生成自己的镜像,并推到私有仓库中,这样可以大大提高拉取镜像的效率。
- [root@harbor ~] wget https://github.com/vmware/harbor/releases/download/v1.8.6/harbor-offline-installer-v1.8.6.tgz
- [root@harbor ~]# tar -xvf harbor-offline-installer-v1.8.6.tgz
(1)修改harbor.yml配置文件
(2)运行install.sh脚本
[root@harbor harbor]# ./install.sh
(3)访问Harbor并登录
(4)创建systemd服务管理脚本
- [Unit]
- Description=Harbor
- After=docker.service systemd-networkd.service systemd-resolved.service
- Requires=docker.service
- Documentation=http://github.com/vmware/harbor
-
- [Service]
- Type=simple
- Restart=on-failure
- RestartSec=5
- ExecStart=/usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml up
- ExecReload=/usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml restart
- ExecStop=/usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml down
-
- [Install]
- WantedBy=multi-user.target
[root@master ~]# vim /etc/docker/daemon.json
- systemctl daemon-reload
- systemctl restart docker
- [root@master ~]# docker tag hello-world 192.168.10.103/library/hello-world:v1
- [root@master ~]# docker push 192.168.10.103/library/hello