四、测试上传和下载镜像
1.修改各docker client配置
# vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd --insecure-registry rgs.unixfbi.com
增加 --insecure-registry rgs.unixfbi.com 即可。
重启docker:
# systemctl daemon-reload
# systemctl restart docker
或者
创建/etc/docker/daemon.json文件,在文件中指定仓库地址
# cat > /etc/docker/daemon.json << EOF
{ "insecure-registries":["rgs.unixfbi.com"] }
EOF
然后重启docker就可以。
# systemctl restart docker
这样设置完成后,就不会提示我们使用https的错误了。
2.创建Dockerfile
# vim Dockerfile
FROM centos:centos7.1.1503
ENV TZ "Asia/Shanghai"
3.创建镜像
# docker build -t rgs.unixfbi.com/library/centos7.1:0.1 .
4.把镜像push到Harbor
# docker login rgs.unixfbi.com
# docker push rgs.unixfbi.com/library/centos7.1:0.1
如果不是自己创建的镜像,记得先执行 docker tags 给镜像做tag
例如:
# docker pull busybox
# docker tag busybox:latest rgs.unixfbi.com/library/busybox:latest
# docker push rgs.unixfbi.com/library/busybox:latest
5.登录web页面查看镜像
201710110454346.png
6.pull镜像
从别的机器上拉一下镜像
# docker rmi -f $(docker images -q -a )
# docker pull rgs.unixfbi.com/library/centos7.1:0.10.1: Pulling from library/centos7.107618ba636d9: Pull complete
Digest: sha256:7f398052ae0e93ddf96ba476185c7f436b15abd27acd848a24b88ede4bb3c322
Status: Downloaded newer image for rgs.unixfbi.com/library/centos7.1:0.1# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
rgs.unixfbi.com/library/centos7.1 0.1 6c849613a995 5 hours ago 212MB |