文章目录
- 1、上传镜像
- 1.1、在Harbor上创建一个项目
- 1.2、docker添加安全访问权限
- 1.3、推送docker镜像到该项目中
- 1.3.1、登录到Harbor
- 1.3.2、给镜像重新打一个标签
- 1.3.3、推送镜像到Harbor中
- 2、拉取镜像
- 2.1、先删掉原来的镜像
- 2.2、执行拉取命令
1、上传镜像
需求:将本地的 centos7-jdk17:latest
镜像上传到Harbor中
实现步骤:
1.1、在Harbor上创建一个项目
1.2、docker添加安全访问权限
# 编辑/etc/docker/daemon.json文件
vim /etc/docker/daemon.json
# 添加安全访问权限
{
"insecure-registries":["http://192.168.74.148:81"],
"registry-mirrors": ["https://5dfryjrh.mirror.aliyuncs.com"]
}
# 重启Docker
systemctl restart docker
1.3、推送docker镜像到该项目中
# 登录到Harbor
docker login -u admin -p Harbor12345 192.168.74.148:81
# 给镜像重新打一个标签
docker tag centos7-jdk17:latest 192.168.74.148:81/centos7-jdk17/centos7-jdk17:test
# 推送镜像到Harbor中
docker push 192.168.74.148:81/centos7-jdk17/centos7-jdk17:test
1.3.1、登录到Harbor
[root@localhost harbor]# docker login -u admin -p Harbor12345 192.168.74.148:81
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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
1.3.2、给镜像重新打一个标签
[root@localhost harbor]# docker tag centos7-jdk17:latest 192.168.74.148:81/centos7-jdk17/centos7-jdk17:test
1.3.3、推送镜像到Harbor中
[root@localhost harbor]# docker push 192.168.74.148:81/centos7-jdk17/centos7-jdk17:test
The push refers to repository [192.168.74.148:81/centos7-jdk17/centos7-jdk17]
0b8b72247609: Pushed
6565928488ea: Pushed
174f56854903: Pushed
test: digest: sha256:a062c0f68411673481807529eb42d31ca0d3051927f2bbb230c9ebbeb8c54421 size: 949
2、拉取镜像
# 登录到Harbor
docker login -u admin -p Harbor12345 192.168.74.148:81
# 拉取镜像
docker pull 192.168.74.148:81/ebuy-docker/ebuy-docker:test
2.1、先删掉原来的镜像
[root@localhost harbor]# docker rmi 192.168.74.148:81/centos7-jdk17/centos7-jdk17:test
Untagged: 192.168.74.148:81/centos7-jdk17/centos7-jdk17:test
Untagged: 192.168.74.148:81/centos7-jdk17/centos7-jdk17@sha256:a062c0f68411673481807529eb42d31ca0d3051927f2bbb230c9ebbeb8c54421
2.2、执行拉取命令
docker pull 192.168.74.148:81/centos7-jdk17/centos7-jdk17@sha256:a062c0f68411673481807529eb42d31ca0d3051927f2bbb230c9ebbeb8c54421
[root@localhost harbor]# docker pull 192.168.74.148:81/centos7-jdk17/centos7-jdk17@sha256:a062c0f68411673481807529eb42d31ca0d3051927f2bbb230c9ebbeb8c54421
192.168.74.148:81/centos7-jdk17/centos7-jdk17@sha256:a062c0f68411673481807529eb42d31ca0d3051927f2bbb230c9ebbeb8c54421: Pulling from centos7-jdk17/centos7-jdk17
Digest: sha256:a062c0f68411673481807529eb42d31ca0d3051927f2bbb230c9ebbeb8c54421
Status: Downloaded newer image for 192.168.74.148:81/centos7-jdk17/centos7-jdk17@sha256:a062c0f68411673481807529eb42d31ca0d3051927f2bbb230c9ebbeb8c54421
192.168.74.148:81/centos7-jdk17/centos7-jdk17@sha256:a062c0f68411673481807529eb42d31ca0d3051927f2bbb230c9ebbeb8c54421