https://www.cnblogs.com/zeppelin/p/5906410.html

接着上篇,上面为上篇地址。

#通过docker tag将该镜像标志为要推送到私有仓库

[root@lh- ~]# sudo docker tag ubuntu 192.168.0.34:/ubuntu
Error response from daemon: no such id: ubuntu
[root@lh- ~]# sudo docker tag docker.io/ubuntu 192.168.0.34:/ubuntu
Error response from daemon: no such id: docker.io/ubuntu
[root@lh- ~]# sudo docker tag 3876b81b5a81 192.168.0.34:/ubuntu

#查看镜像

[root@lh- ~]# docker images
192.168.0.34:/ubuntu latest 3876b81b5a81 months ago 187.9 MB
docker.io/ubuntu 14.04. 3876b81b5a81 months ago 187.9 MB

#提交ubuntu镜像到私有仓库

[root@lh- ~]# sudo docker push 192.168.0.34:/ubuntu
The push refers to a repository [192.168.0.34:/ubuntu]
5f70bf18a086: Pushed
0d81735d8272: Pushed
982549bd6b32: Pushed
8698b31c92d5: Pushed
latest: digest: sha256:a47804d268c600572aab1f564e38d1ef009bd7c7ce4bbd325be51973541e5431 size:

#进入容器

[root@lh- data]# docker exec -it 6cb333619b90 /bin/sh
/ # ls
bin entrypoint.sh home linuxrc mnt root sbin sys usr
dev etc lib media proc run srv tmp var
/ # cd /tmp/registry/
/tmp/registry # ls
/tmp/registry #

发现还是没有镜像

#镜像在容器的/var/lib/registry目录下

~ # cd /var/lib/registry/docker/registry/v2/repositories/
/var/lib/registry/docker/registry/v2/repositories # ls
busybox nginx ubuntu
/var/lib/registry/docker/registry/v2/repositories # ll
/bin/sh: ll: not found
/var/lib/registry/docker/registry/v2/repositories # ls -l
total
drwxr-xr-x root root Sep : busybox
drwxr-xr-x root root Sep : nginx
drwxr-xr-x root root Sep : ubuntu
/var/lib/registry/docker/registry/v2/repositories #

#切换映射目录

[root@lh- registry]# docker run -d -p : -v /opt/data/registry:/var/lib/registry docker.io/registry
bc2304a84ec4cd7eed6b0dabd929141990d2e4f11253941a1fe28856c255aa06
[root@lh- registry]# docker push 192.168.0.34:/busybox
The push refers to a repository [192.168.0.34:/busybox]
8ac8bfaff55a: Retrying in seconds
Received unexpected HTTP status: Internal Server Error

问题:push镜像报错。

#解决办法:

给这个容器扩展的特权--privileged=true

[root@lh- registry]# docker run -d -p : -v /opt/data/registry:/var/lib/registry --privileged=true docker.io/registry
23397ef79ec57f6a077dd50c8ff449c3a1dd6b21b8c13f6e210775ec0975412e

注:这儿只有加特权才可行,后面我用了registry:2镜像没有这个问题了,估计是最新版本镜像的问题吧。

#提交镜像到本地仓库中

[root@lh- registry]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.0.34:/busybox latest 2b8fd9751c4c weeks ago 1.093 MB
[root@lh- registry]# docker push 192.168.0.34:/busybox
The push refers to a repository [192.168.0.34:/busybox]
8ac8bfaff55a: Pushed
latest: digest: sha256:a59906e33509d14c036c8678d687bd4eec81ed7c4b8ce907b888c607f6a1e0e6 size:

发现可以push上去了。

[root@lh- registry]# ls /opt/data/registry/docker/registry/v2/repositories/
Busybox
[root@lh- registry]# curl -XGET 192.168.0.34:/v2/_catalog
{"repositories":["busybox"]}

#进入容器看一下镜像实际存储位置

[root@lh- registry]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
23397ef79ec5 docker.io/registry "/entrypoint.sh /etc/" minutes ago Up minutes 0.0.0.0:->/tcp berserk_hypatia
[root@lh- registry]# docker exec -it 23397ef79ec5 /bin/sh
/ # ls
bin entrypoint.sh home linuxrc mnt root sbin sys usr
dev etc lib media proc run srv tmp var
/ # cd /var/lib/registry/docker/registry/v2/repositories/
/var/lib/registry/docker/registry/v2/repositories # ls
busybox

#查看镜像的存储目录树

[root@lh- registry]# tree /opt/data/registry/docker/registry/v2/repositories/
/opt/data/registry/docker/registry/v2/repositories/
└── busybox
├── _layers
│   └── sha256
│   ├── 2b8fd9751c4c0f5dd266fcae00707e67a2545ef34f9a29354585f93dac906749
│   │   └── link
│   └── 8ddc19f16526912237dd8af81971d5e4dd0587907234be2b83e249518d5b673f
│   └── link
├── _manifests
│   ├── revisions
│   │   └── sha256
│   │   └── a59906e33509d14c036c8678d687bd4eec81ed7c4b8ce907b888c607f6a1e0e6
│   │   └── link
│   └── tags
│   └── latest
│   ├── current
│   │   └── link
│   └── index
│   └── sha256
│   └── a59906e33509d14c036c8678d687bd4eec81ed7c4b8ce907b888c607f6a1e0e6
│   └── link
└── _uploads directories, files

测试放到下篇。

https://www.cnblogs.com/zeppelin/p/5906444.html

个人公众号,定期分享大数据与知识图谱相关知识点,读书思考:

Docker私有仓库2的更多相关文章

  1. 一步步搭建docker私有仓库并从私有仓库中下载镜像

    一步步搭建docker私有仓库 #下载镜像 docker pull registry#查看镜像 docker images #运行私有仓库,指定端口和数据卷 docker run -d -p : -v ...

  2. 搭建docker私有仓库,建立k8s集群

    服务器IP角色分布 192.168.5.2 etcd server 192.168.5.2 kubernetes master 192.168.5.3 kubernetes node 192.168. ...

  3. docker 私有仓库镜像的存储位置

    docker 私有仓库的镜像 是存储在5739360d1030 registry "docker-registry" 3 days ago Up 28 hours 0.0.0.0: ...

  4. 在docker私有仓库如何查看有哪些镜像?

    搭建了docker私有仓库,上传了一些镜像,时间长了就会忘了有哪些镜像,在网上查了,有大佬是通过脚本查看的,多厉害! #!/usr/bin/env python#-*- coding:utf-8 -* ...

  5. 转载:教你分分钟搞定Docker私有仓库Registry

    一.什么是Docker私有仓库Registry 官方的Docker hub是一个用于管理公共镜像的好地方,我们可以在上面找到我们想要的镜像,也可以把我们自己的镜像推送上去.但是,有时候我们的服务器无法 ...

  6. Docker 私有仓库建立(加密和用户验证)

    (一)生成证书1.mkdir /certs2.cd /certs 3.生成自签名证书 sudo openssl req -newkey rsa:2048 -new -nodes -x509 -days ...

  7. 搭建docker私有仓库(https)

    1.修改openssl.cnf,支持IP地址方式,HTTPS访问在Redhat7或者Centos系统中,文件所在位置是/etc/pki/tls/openssl.cnf.在其中的[ v3_ca]部分,添 ...

  8. 搭建docker私有仓库

    保存镜像的地方成为仓库(registry).目前有2种仓库:公共仓库和私有仓库. 最方便的是使用公共仓库上传和下载镜像,下载不需要注册,上传需要到公共仓库注册.公共仓库网站:https://hub.d ...

  9. 教你分分钟搞定Docker私有仓库Registry

    一.什么是Docker私有仓库Registry 官方的Docker hub是一个用于管理公共镜像的好地方,我们可以在上面找到我们想要的镜像,也可以把我们自己的镜像推送上去.但是,有时候我们的服务器无法 ...

  10. docker 私有仓库简易搭建

    概要 本地私有仓库 局域网私有仓库 总结 概要 docker hub 使用非常方便,而且上面有大量的镜像可以使用. 但是,每次都远程下载镜像速度非常慢,如果能在本地做一个 docker 的仓库,多人协 ...

随机推荐

  1. PHP 在 Nginx 下主动断开连接 Connection Close 与 ignore_user_abort 后台运行

    这两天弄个PHP调用 SVN 同步 update 多台服务器更新的程序,为了避免 commit 的时候不会被阻塞卡半天得想个办法只请求触发,而不需要等待程序 update 完成返回结果这样耗时太长,所 ...

  2. CSU 1811 Tree Intersection

    莫队算法,$dfs$序. 题目要求计算将每一条边删除之后分成的两棵树的颜色的交集中元素个数. 例如删除$u->v$,我们只需知道以$v$为$root$的子树中有多少种不同的颜色(记为$qq$), ...

  3. php error _report

    [error_reporting] => Array   (   [global_value] => 32767   [local_value] => 0   [access] =& ...

  4. Java多线程的信号量

    Java的信号量主要的作用是控制线程对资源的访问例如我一个线程池里面有100个线程等待执行,但是我允许最多同时运行5个线程,这5个线程只有其中一个线程执行完毕后,在线程池中等待的线程才能进入开始执行, ...

  5. matlab里textread出现错误“Trouble reading floating point number from file (row 1, field 1)”

    matlab里textread出现错误“Trouble reading floating point number from file (row 1, field 1)” 解决办法:traindata ...

  6. 免费DDOS攻击测试工具大合集

    FreeBuf微科普: DoS(Denial Of Service)攻击是指故意的攻击网络协议实现的缺陷或直接通过野蛮手段残忍地耗尽被攻击对象的资源,目的是让目标计算机或网络无法提供正常的服务或资源访 ...

  7. C# 正则表达式 结合 委托

    使用正则表达式匹配字符串的同时,使用委托事件,处理每一个匹配项 示例代码: string msg = "我的邮箱是zxh@itcast.cn的邮箱是yzk365@chezhihui.com减 ...

  8. chrome下li标签onclick事件无效

    //绑定事件 $(document).ready(function () { $("ul").children().click(function () { clickLi(this ...

  9. iOS TableView的分割线

    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) { [self.tableView setSeparato ...

  10. qt5.6 for android

    尝试在qt下写android的程序.测试,没有编译成功. 在选项-android配置页面,提示有"Qt version for 3 architectures are missing&quo ...