上传镜像到仓库

这篇具有很好参考价值的文章主要介绍了上传镜像到仓库。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

上传镜像到仓库,容器-docker,容器,docker

上传镜像到公开仓库

1、给要上传的镜像打标签

# 从206节点上传镜像到仓库(201)magedu项目,查看206镜像
[root@k8s-node2 ~]# docker images
REPOSITORY                                                  TAG           IMAGE ID       CREATED         SIZE
registry                                                    latest        b2cb11db9d3d   2 weeks ago     26.2MB
centos7.9                                                   v4.0          f9fa966f3abe   3 weeks ago     211MB
centos7.9                                                   v3.0          9d181c779007   3 weeks ago     204MB
centos7.9                                                   v2.0          c06d6e414d47   3 weeks ago     204MB
centos7.9                                                   v1.0          a7501b2f31f1   3 weeks ago     204MB
registry.cn-hangzhou.aliyuncs.com/gxy_docker2021/centos     7.9.2009-v2   8652b9f0cb4c   10 months ago   204MB
registry.cn-hangzhou.aliyuncs.com/gxy_docker2021/gxy_test   v1.0          8652b9f0cb4c   10 months ago   204MB
guoxuyang6888/centos                                        7.9.2009-v1   8652b9f0cb4c   10 months ago   204MB
centos                                                      7.9.2009      8652b9f0cb4c   10 months ago   204MB

2、查看打标签命令
上传镜像到仓库,容器-docker,容器,docker
上传镜像到仓库,容器-docker,容器,docker

3、复制到终端进行修改

# 给镜像打标签,格式:docker tag SOURCE_IMAGE[:TAG] 192.168.31.201/magedu/REPOSITORY[:TAG] 前边是源镜像,后边是传到仓库后的镜像,可以重名了
[root@k8s-node2 ~]# docker tag centos7.9:v4.0 192.168.31.201/magedu/centos7.9:v4.0

4、上传镜像到公开仓库

# 格式:docker push 打好tar的镜像:版本号,注意,打好tar的镜像格式是:仓库地址/项目/要上传的镜像:版本号,这里上传的时候不需要在push后在加仓库地址和项目目录了,因为打好的tar的镜像中包含,直接docker push + 要上传的镜像:版本即可
[root@k8s-node2 ~]# docker push 192.168.31.201/magedu/192.168.31.201/magedu/centos7.9:v4.0
The push refers to repository [192.168.31.201/magedu/192.168.31.201/magedu/centos7.9]
An image does not exist locally with the tag: 192.168.31.201/magedu/192.168.31.201/magedu/centos7.9
[root@k8s-node2 ~]# 
[root@k8s-node2 ~]# 
[root@k8s-node2 ~]# docker push 192.168.31.201/magedu/centos7.9:v4.0
The push refers to repository [192.168.31.201/magedu/centos7.9]
c5fb9f0f3efb: Pushed 
c406384a2b40: Pushed 
174f56854903: Pushed 
v4.0: digest: sha256:2aae8a55a7ee6e82fa88aa770964b49c624dce481362bf2fe89bc8159665174d size: 951

5、查看上传的镜像
上传镜像到仓库,容器-docker,容器,docker
上传镜像到仓库,容器-docker,容器,docker

6、下载镜像

从另外一台机器(205)下载206节点上传的镜像

# 登录205节点,查看当前镜像,确保不含206上传的镜像
[root@k8s-node1 ~]# docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
nginx                             latest    ad4c705f24d3   7 days ago    133MB
[root@k8s-node1 ~]# 

7、查看镜像拉取命令
上传镜像到仓库,容器-docker,容器,docker

# 登录205节点进行拉取
[root@k8s-node1 ~]# docker pull 192.168.31.201/magedu/centos7.9@sha256:2aae8a55a7ee6e82fa88aa770964b49c624dce481362bf2fe89bc8159665174d
Error response from daemon: Get "https://192.168.31.201/v2/": dial tcp 192.168.31.201:443: connect: connection refused

8、排错:此时我们发现请求被拒了,因为docker harbor默认是https请求,我们创建的时候走的是http,我们需要修改205节点的/lib/systemd/system/docker.service

# 修改第13行,在后边添加仓库的地址:--insecure-registry 192.168.31.201 --insecure-registry 192.168.31.204
[root@k8s-node1 ~]# vim /lib/systemd/system/docker.service
...
11 # exists and systemd currently does not support the cgroup feature set required
 12 # for containers run by docker
 13 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry 192.168.31.201 --insecure-registry 192.168.31.204
 14 ExecReload=/bin/kill -s HUP $MAINPID
 ...

9、重启docker

[root@k8s-node1 ~]# systemctl daemon-reload
[root@k8s-node1 ~]# systemctl restart docker

10、重新拉取

# 拉取成功
[root@k8s-node1 ~]# docker pull 192.168.31.201/magedu/centos7.9@sha256:2aae8a55a7ee6e82fa88aa770964b49c624dce481362bf2fe89bc8159665174d
192.168.31.201/magedu/centos7.9@sha256:2aae8a55a7ee6e82fa88aa770964b49c624dce481362bf2fe89bc8159665174d: Pulling from magedu/centos7.9
2d473b07cdd5: Pull complete 
017960a6d76e: Pull complete 
8ee6fdd9e641: Pull complete 
Digest: sha256:2aae8a55a7ee6e82fa88aa770964b49c624dce481362bf2fe89bc8159665174d
Status: Downloaded newer image for 192.168.31.201/magedu/centos7.9@sha256:2aae8a55a7ee6e82fa88aa770964b49c624dce481362bf2fe89bc8159665174d
192.168.31.201/magedu/centos7.9@sha256:2aae8a55a7ee6e82fa88aa770964b49c624dce481362bf2fe89bc8159665174d

11、查看下载后的镜像

[root@k8s-node1 ~]# docker images
REPOSITORY                        TAG       IMAGE ID       CREATED       SIZE
192.168.31.201/magedu/centos7.9   <none>    f9fa966f3abe   3 weeks ago   211MB
nginx                             latest    ad4c705f24d3   7 days ago    133MB

上传镜像到私有仓库

打标签

# 本次从205上传镜像到私有仓库test
[root@k8s-node1 ~]# docker tag nginx:latest 192.168.31.201/test/nginx:v1.0

查看打过标签的镜像

[root@k8s-node1 ~]# docker images
REPOSITORY                        TAG       IMAGE ID       CREATED       SIZE
192.168.31.201/test/nginx         v1.0      ad4c705f24d3   7 days ago    133MB
nginx                             latest    ad4c705f24d3   7 days ago    133MB
192.168.31.201/magedu/centos7.9   <none>    f9fa966f3abe   3 weeks ago   211MB

上传镜像到私有仓库test

[root@k8s-node1 ~]# docker push 192.168.31.201/test/nginx:v1.0
The push refers to repository [192.168.31.201/test/nginx]
fac15b2caa0c: Preparing 
f8bf5746ac5a: Preparing 
d11eedadbd34: Preparing 
797e583d8c50: Preparing 
bf9ce92e8516: Preparing 
d000633a5681: Waiting 
unauthorized: unauthorized to access repository: test/nginx, action: push: unauthorized to access repository: test/nginx, action: push

排错:上传镜像是提示未认证的用户,需要认证后才能上传

查看镜像是否上传成功
上传镜像到仓库,容器-docker,容器,docker
发现没有上传成功

解决办法:

登录仓库

# 登录仓库,用户admin 密码123456
[root@k8s-node1 ~]# docker login 192.168.31.201
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

重新上传

[root@k8s-node1 ~]# docker push 192.168.31.201/test/nginx:v1.0
The push refers to repository [192.168.31.201/test/nginx]
fac15b2caa0c: Pushed 
f8bf5746ac5a: Pushed 
d11eedadbd34: Pushed 
797e583d8c50: Pushed 
bf9ce92e8516: Pushed 
d000633a5681: Pushed 
v1.0: digest: sha256:6fe11397c34b973f3c957f0da22b09b7f11a4802e1db47aef54c29e2813cc125 size: 1570

查看上传后的镜像
上传镜像到仓库,容器-docker,容器,docker
上传镜像到仓库,容器-docker,容器,docker
上传成功!

下载镜像

# 从206上下载镜像
[root@k8s-node2 ~]# docker pull 192.168.31.201/test/nginx@sha256:6fe11397c34b973f3c957f0da22b09b7f11a4802e1db47aef54c29e2813cc125
192.168.31.201/test/nginx@sha256:6fe11397c34b973f3c957f0da22b09b7f11a4802e1db47aef54c29e2813cc125: Pulling from test/nginx
a330b6cecb98: Pull complete 
e0ad2c0621bc: Pull complete 
9e56c3e0e6b7: Pull complete 
09f31c94adc6: Pull complete 
32b26e9cdb83: Pull complete 
20ab512bbb07: Pull complete 
Digest: sha256:6fe11397c34b973f3c957f0da22b09b7f11a4802e1db47aef54c29e2813cc125
Status: Downloaded newer image for 192.168.31.201/test/nginx@sha256:6fe11397c34b973f3c957f0da22b09b7f11a4802e1db47aef54c29e2813cc125
192.168.31.201/test/nginx@sha256:6fe11397c34b973f3c957f0da22b09b7f11a4802e1db47aef54c29e2813cc125

查看镜像

[root@k8s-node2 ~]# docker images
REPOSITORY                                                  TAG           IMAGE ID       CREATED         SIZE
192.168.31.201/test/nginx                                   <none>        ad4c705f24d3   7 days ago      133MB
registry                                                    latest        b2cb11db9d3d   2 weeks ago     26.2MB
centos7.9                                                   v4.0          f9fa966f3abe   3 weeks ago     211MB
192.168.31.201/magedu/centos7.9                             v4.0          f9fa966f3abe   3 weeks ago     211MB
centos7.9                                                   v3.0          9d181c779007   3 weeks ago     204MB
centos7.9                                                   v2.0          c06d6e414d47   3 weeks ago     204MB
centos7.9                                                   v1.0          a7501b2f31f1   3 weeks ago     204MB
guoxuyang6888/centos                                        7.9.2009-v1   8652b9f0cb4c   10 months ago   204MB
centos                                                      7.9.2009      8652b9f0cb4c   10 months ago   204MB
registry.cn-hangzhou.aliyuncs.com/gxy_docker2021/centos     7.9.2009-v2   8652b9f0cb4c   10 months ago   204MB
registry.cn-hangzhou.aliyuncs.com/gxy_docker2021/gxy_test   v1.0          8652b9f0cb4c   10 months ago   204MB

下载成功!

注意: 由于206已经登录过镜像仓库了,并且在家目录下的 .docker目录中生成了config.json文件,所有下次登录仓库无需账号密码,所以从私有仓库下载也无需登录了。

[root@k8s-node2 ~]# cat .docker/config.json 
{
        "auths": {
                "192.168.31.201": {
                        "auth": "YWRtaW46MTIzNDU2"
                },
                "https://index.docker.io/v1/": {
                        "auth": "Z3VveHV5YW5nNjg4ODpndW94dXlhbmcxOTkx"
                },
                "registry.cn-hangzhou.aliyuncs.com": {
                        "auth": "Z3VveHV5YW5nMTk5MToxcWF6IVFBWg=="
                }
        }
}[root@k8s-node2 ~]# pwd
/root

auth": “Z3VveHV5YW5nNjg4ODpndW94dXlhbmcxOTkx”
},
“registry.cn-hangzhou.aliyuncs.com”: {
“auth”: “Z3VveHV5YW5nMTk5MToxcWF6IVFBWg==”
}
}
}[root@k8s-node2 ~]# pwd
/root文章来源地址https://www.toymoban.com/news/detail-844011.html


到了这里,关于上传镜像到仓库的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 一文搞清楚 Docker 镜像、容器、仓库

    博主介绍 : ✌博主从事应用安全和大数据领域,有8年研发经验,5年面试官经验,Java技术专家✌ Java知识图谱点击链接: 体系化学习Java(Java面试专题) 💕💕 感兴趣的同学可以收藏关注下 , 不然下次找不到哟 💕💕 Docker 镜像、容器、仓库是 Docker 技术中的三个重要概念

    2024年02月03日
    浏览(28)
  • docker <应用分享> 上传镜像到 私有仓库 / 本地仓库,从私库拉取镜像

    前两篇博客写了docker上传镜像到dockerhub,以及上传镜像到阿里云仓库。感兴趣的可以点下面链接 docker上传镜像到dockerhub docker上传镜像到阿里云 前面两种方式都是放在云上,对于一些私密性比较高的东西,总归是不太安全。 这个时候就用到了docker私有仓库,在本地创建一个私

    2023年04月19日
    浏览(20)
  • [Docker]二.Docker 镜像,仓库,容器介绍以及详解

    通俗来讲:镜像相当于VM虚拟机中的ios文件,容器相当于虚拟机系统,仓库相当于系统中的进程或者执行文件,容器是通过镜像创建的 Docker 镜像就是一个 Linux 的文件系统( Root FileSystem ),这个文件系统里面包含可以运行在 Linux 内核的程序以及相应的数据,这里要强调一下镜像的两

    2024年02月03日
    浏览(21)
  • Docker镜像、容器、仓库及数据管理

    使用docker pull命令,使用docker search命令可以搜索远端仓库中共享的镜像。 使用docker run [OPTIONS] IMAGE [COMMAND] [ARG...]命令,如:docker run --name ubuntu_test --rm -it ubuntu:test /bin/bash,其中选项如下: --name 指定容器名。 --rm 表示容器退出后将其删除。 -t选项让Docker分配一个伪终端并绑定

    2024年02月09日
    浏览(23)
  • Docker 基础实战:环境搭建、容器、仓库、镜像

    可以使用 docker help 或者 man docker-run 来获取完整的 Docker 命令列表,本文只介绍一些常用的命令与参数。 考虑到安装流程过于繁琐,在 CentOS 中,可以使用官方提供的脚本来快速安装 Docker: 可以从 https://get.docker.com/ 查看支持的操作系统。 当安装完毕后,设置开机自启动 Doc

    2024年02月16日
    浏览(30)
  • 什么是docker(docker客户端、镜像、容器、仓库)

    Docker 是一个开源的容器化平台,它可以让开发者打包应用程序及其依赖项成为一个轻量级、可移植的容器,然后在任何环境中运行。Docker 容器将应用程序及其依赖项打包到一个标准化单元中,包括代码、运行时环境、系统工具、系统库等,确保应用程序在不同的环境中具有

    2024年04月10日
    浏览(21)
  • 将docker本地镜像上传远程dockerhub仓库

    将docker本地镜像上传远程dockerhub仓库,实现在其他设备上无需建立dockerfile文件来制作镜像。 首先在本地使用dockerfile制作好镜像,并启动容器。 通过 docker images 可以查看到镜像,docker ps -a 可以查看到容器 dockerhub官网:添加链接描述 通过Create repository创建仓库,输入仓库名和

    2024年02月15日
    浏览(33)
  • 面向对象视角下,理解Docker 镜像容器和仓库

    今天带大家在面向对象的视角下,理解镜像,容器和仓库到底是什么关系,相信大家读完本文一定会有更深刻的理解。 注:面向对象语言有很多,本文基于Java语言进行描述 首先创建一个类,用来模拟 Docker 中的一个镜像 tomcat8,其中暴露了一个获取版本号和启动的方法 创建

    2024年01月19日
    浏览(22)
  • 7-Docker私有仓库harbor私有镜像上传配置

    1.编辑/etc/docker/daemon.json文件,修改容器仓库配置,并保存 命令: vim /etc/docker/daemon.json 更新前 更新后 2.重启docker及Harbor 命令: cd /usr/local/harbor docker-compose -f docker-compose.yml down -v docker-compose ps -a systemctl stop docker systemctl status docker systemctl start docker systemctl status docker docker-comp

    2024年01月23日
    浏览(33)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包