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

目录
打赏
0
0
0
0
41
分享
相关文章
云效flow构建docker镜像更换apt源为阿里镜像源
在 Dockerfile 中添加命令以更换 Debian 源为阿里云镜像,加速容器内软件包下载。核心命令通过 `sed` 实现源地址替换,并更新 apt 软件源。其中 `cat` 命令用于验证替换是否成功,实际使用中可删除该行。
645 32
将应用程序打包成Docker镜像时可能遇到哪些问题?
将应用程序打包成Docker镜像时可能遇到哪些问题?
261 77
Ubuntu Docker镜像:支持systemctl、SSH、VNC
总的来说,创建一个支持systemctl、SSH和VNC的Ubuntu Docker镜像需要一些技术知识,但是通过学习和实践,我们可以掌握这些技术。这将使我们能够更有效地使用Docker,更好地管理我们的应用程序和服务。CentOS系统中的日志文件位置和管理
117 17
Docker镜像:Ubuntu支持systemctl、SSH和VNC
总的来说,Docker提供了一个灵活且强大的方式来创建和运行自定义的Ubuntu镜像。通过理解和使用Dockerfile,你可以轻松地创建一个支持systemctl、SSH和VNC的Ubuntu镜像。
218 21
Docker网关冲突导致容器启动网络异常解决方案
当执行`docker-compose up`命令时,服务器网络可能因Docker创建新网桥导致IP段冲突而中断。原因是Docker默认的docker0网卡(172.17.0.1/16)与宿主机网络地址段重叠,引发路由异常。解决方法为修改docker0地址段,通过配置`/etc/docker/daemon.json`调整为非冲突段(如192.168.200.1/24),并重启服务。同时,在`docker-compose.yml`中指定网络模式为`bridge`,最后通过检查docker0地址、网络接口列表及测试容器启动验证修复效果。
【赵渝强老师】数据库不适合Docker容器化部署的原因
本文介绍了在Docker中部署MySQL数据库并实现数据持久化的方法,同时分析了数据库不适合容器化的原因。通过具体步骤演示如何拉取镜像、创建持久化目录及启动容器,确保数据安全存储。然而,由于数据安全性、硬件资源争用、网络带宽限制及额外隔离层等问题,数据库服务并不完全适合Docker容器化部署。文中还提到数据库一旦部署通常无需频繁升级,与Docker易于重构和重新部署的特点不符。
215 18
【赵渝强老师】数据库不适合Docker容器化部署的原因
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等