Harbor仓库使用
登录Web Harbor
上传镜像到Harbor仓库
我们新建一个名称为harbor的项目,设置不公开。当项目设为公开后,任何人都有此项目下镜像的读权限。命令行用户不需要docker login就可以拉取此项目下的镜像
admin登录
- 使用docker login出现如下问题:
[root@localhost harbor]# docker login 192.168.31.20
Username: admin
Password:
Error response from daemon: Get https://192.168.31.20/v2/: dial tcp 192.168.31.20:443: connect: connection refused
解决方法:
- 修改docker客户端配置 vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry=192.168.31.20:9191
备注:增加harbor私有仓库地址,告知客户端要连接http的端口
2. 重启docker服务
3. 重启harbor ./install.sh
4. 重新进行登录尝试
[root@localhost harbor]# docker login 192.168.31.20:9191
Username: admin
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
注:修改参数后,必须要将docker进程进行重启,否则仍然登录失败。
pull 镜像到仓库
[root@localhost ~]# docker push 192.168.126.162/harbor/nginx:latest
The push refers to repository [192.168.126.162/harbor/nginx]
3569f62067e2: Pushed
3f117c44afbb: Pushed
c4a8b7411af4: Pushed
fe4c16cbf7a4: Pushed
latest: digest: sha256:3dce35afeadd7195877b17bf1514b9e388ed671afe428441fe5e0b02cdc26eeb size: 1160
Harbor 项目页面中有标记和上传镜像的命令,复制下改下名字,直接用就可以了
推送镜像的Docker命令
在项目中标记镜像:
docker tag SOURCE_IMAGE[:TAG] 192.168.31.20:9191/image-cws/IMAGE[:TAG]
docker tag SOURCE_IMAGE[:TAG] 192.168.31.20:9191/image-cws/IMAGE[:TAG]
推送镜像到当前项目:
docker push 192.168.31.20:9191/image-cws/IMAGE[:TAG]
这样就完成了上传镜像和摘取镜像的操作