docker镜像上传至Harbor及从Harbor下载

简介: docker镜像上传至Harbor及从Harbor下载

docker镜像上传至Harbor及从Harbor下载
合集 - docker(15)
1.
docker 系统架构
09-06
2.
docker的安装
09-06
3.
docker 初步使用
09-06
4.
docker 容器的操作命令选项
09-07
5.
★ docker镜像的常见操作
09-22
6.
docker 构建镜像
09-07
7.
docker镜像存储驱动方式
09-27
8.
docker 镜像和容器的关系
09-28
9.
docker 容器内写文件
10-08
10.
私有的docker私有镜像站仓库harbor
10-09
11.
docker镜像上传至Harbor及从Harbor下载
10-11
12.
Dockerfile指令
09-09
13.
docker 容器端口与数据卷
09-12
14.
Docker的共享数据和数据容器
09-19
15.
★ docker的常见操作
09-19
收起
▶ 修改 docker daemon 使用 harbor
▷ 安装 harbor 的主机
在 harbor 的主机中配置。

添加 /etc/docker/daemon.json 文件,默认不存在,需要手动添加。

[root@server harbor]# vim /etc/docker/daemon.json

[root@server harbor]# cat /etc/docker/daemon.json
{
"insecure-registries":["https://www.harborexample.com"]
}
重新加载 daemon 配置。

[root@server harbor]# systemctl daemon-reload
[root@server harbor]# systemctl restart docker
由于是重启 docker 所以 harbor 的9个容器可能会停止,这就需要使用 docker-compose 来使用。

[root@server harbor]# pwd
/home/harbor

[root@server harbor]# docker-compose down
[root@server harbor]# docker-compose up -d

▶ docker push
在其他的安装了docker的主机中,依旧需要在 /etc/docker/daemon.json 文件来配置。

[root@server ~]# vi /etc/docker/daemon.json

[root@server ~]# cat /etc/docker/daemon.json
{
"insecure-registries":["https://www.harborexample.com"]
}

制作准备要 push 的镜像,给该镜像打 tag:

[root@server ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 7f553e8bbc89 8 days ago 192MB

[root@server ~]# docker tag nginx:latest www.harborexample.com/library/ngnix:v1
[root@server ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
www.harborexample.com/library/ngnix v1 7f553e8bbc89 8 days ago 192MB
nginx latest 7f553e8bbc89 8 days ago 192MB
docker tag 镜像 寄存服务registry/仓库repository/镜像:tag

登陆 harbor:

[root@server ~]# docker login https://www.harborexample.com
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/#credential-stores

Login Succeeded

docker push 的具体操作:

[root@server ~]# docker push www.harborexample.com/library/ngnix:v1
The push refers to repository [www.harborexample.com/library/ngnix]
825fb68b6033: Pushed
7619c0ba3c92: Pushed
1c1f11fd65d6: Pushed
6b133b4de5e6: Pushed
3d07a4a7eb2a: Pushed
756474215d29: Pushed
8d853c8add5d: Pushed
v1: digest: sha256:719b34dba7bd01c795f94b3a6f3a5f1fe7d53bf09e79e355168a17d2e2949cef size: 1778
此时在浏览器中查看:

[kod.tongfengstone.com)
[kod.bn47.com)
[kod.ybmqyz.com)
[kod.scacllc.com)
[kod.zhaimeizi.com)
[kod.710082.com)
[kod.gd-yuejin.com)
[kod.512aiai.com)

▶ docker pull
对于要对自己内部的harbor来使用 docker pull,在这之前需要对 /etc/hosts 和 /etc/docker/daemon.json 做配置。

[root@server ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.10 www.harborexample.com

[root@server ~]# cat /etc/docker/daemon.json
{
"insecure-registries":["https://www.harborexample.com"]
}
[root@server ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE

此时并没有镜像的存在。

指定 www.harborexample.com 的来拉取镜像。

[root@server ~]# docker pull www.harborexample.com/library/ngnix:v1
v1: Pulling from library/ngnix
302e3ee49805: Pull complete
d07412f52e9d: Pull complete
9ab66c386e9c: Pull complete
4b563e5e980a: Pull complete
55af3c8febf2: Pull complete
5b8e768fb22d: Pull complete
85177e2c6f39: Pull complete
Digest: sha256:719b34dba7bd01c795f94b3a6f3a5f1fe7d53bf09e79e355168a17d2e2949cef
Status: Downloaded newer image for www.harborexample.com/library/ngnix:v1
www.harborexample.com/library/ngnix:v1
[root@server ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
www.harborexample.com/library/ngnix v1 7f553e8bbc89 8 days ago 192MB
合集: docker

相关文章
|
8月前
|
JavaScript Docker 容器
使用Docker多阶段构建优化镜像大小
使用Docker多阶段构建优化镜像大小
517 100
|
8月前
|
缓存 安全 Linux
优化Docker镜像大小的多阶段构建实践
优化Docker镜像大小的多阶段构建实践
505 99
|
8月前
|
缓存 Docker 容器
优化Docker镜像大小的五个实用技巧
优化Docker镜像大小的五个实用技巧
742 98
|
8月前
|
安全 Go Docker
使用Docker多阶段构建优化镜像大小
使用Docker多阶段构建优化镜像大小
|
7月前
|
NoSQL 算法 Redis
【Docker】(3)学习Docker中 镜像与容器数据卷、映射关系!手把手带你安装 MySql主从同步 和 Redis三主三从集群!并且进行主从切换与扩容操作,还有分析 哈希分区 等知识点!
Union文件系统(UnionFS)是一种**分层、轻量级并且高性能的文件系统**,它支持对文件系统的修改作为一次提交来一层层的叠加,同时可以将不同目录挂载到同一个虚拟文件系统下(unite several directories into a single virtual filesystem) Union 文件系统是 Docker 镜像的基础。 镜像可以通过分层来进行继承,基于基础镜像(没有父镜像),可以制作各种具体的应用镜像。
775 6
|
8月前
|
Java Docker 容器
使用Docker多阶段构建优化镜像大小
使用Docker多阶段构建优化镜像大小
339 8
|
9月前
|
缓存 Ubuntu Docker
Ubuntu环境下删除Docker镜像与容器、配置静态IP地址教程。
如果遇见问题或者想回滚改动, 可以重启系统.
549 16
|
Linux 开发工具 数据安全/隐私保护
Docker部署Harbor
配合Kubernetes集群日常的发布,jenkins构建镜像推送到私有镜像仓库,这里选择部署harbor
569 0

热门文章

最新文章