习Docker的过程中Docker的私有仓库一直没能成功,就是因为CentOS 6.x和CentOS 7默认引入了支持https认证,每次在push和pull的时候都会报错,今天是周末,利用一天的时间反复测试和网上案列的整合,总算是成功了,也借此机会对学习Docker的朋友有所帮助。
个人的愚见:博友在练习的时候建议用CentOS 7.x系统,不建议用CentOS 6.x系统

一、准备
地址规划:
Docker私有仓库地址:192.168.0.109
Docker客户端地址:192.168.0.110
1、激活网卡
# vim /etc/sysconfig/network-scripts/ifcfg-eno16777728
修改此行
ONBOOT=yes
# /etc/init.d/network restart
2、关闭本地防火墙并设置开机不自启动
# systemctl stop firewalld.service
# systemctl disable firewalld.service
3、关闭本地selinux防火墙

# vi /etc/sysconfig/selinux
SELINUX=disabled
# setenforce 0
4、安装ifconfig工具

# yum install net-tools
二、安装
1、安装docker
# yum install docker
# yum upgrade device-mapper-libs
# service docker start
# chkconfig docker on
2、本地私有仓库registry
[root@localhost ~]# docker pull registry
Trying to pull repository docker.io/registry ...
24dd746e9b9f: Download complete
706766fe1019: Download complete
a62a42e77c9c: Download complete
2c014f14d3d9: Download complete
b7cf8f0d9e82: Download complete
d0b170ebeeab: Download complete
171efc310edf: Download complete
522ed614b07a: Download complete
605ed9113b86: Download complete
22b93b23ebb9: Download complete
2ac557a88fda: Download complete
1f3b4c532640: Download complete
27ebaac643a7: Download complete
ce630195cb45: Download complete
Status: Downloaded newer image for docker.io/registry:latest
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
docker.io/registry latest 24dd746e9b9f 3 days ago 413.8 MB
3、基于私有仓库镜像运行容器
[root@localhost ~]# docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry docker.io/registry
bb2c0d442df94e281479332c2608ef144f378e71743c5410e36b80c465771a95
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bb2c0d442df9 docker.io/registry:latest "docker-registry" 10 seconds ago Up 7 seconds 0.0.0.0:5000->5000/tcp serene_hopper
4、访问私有仓库
[root@localhost ~]# curl 127.0.0.1:5000/v1/search
{"num_results": 0, "query": "", "results": []} //私有仓库为空,没有提交新镜像到仓库中
5、从Docker Hub上下载一个ssh镜像
[root@localhost ~]# docker search -s 10 ssh
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io: docker.io/fedora/ssh 18 [OK]
[root@localhost ~]# docker pull fedora/ssh
Trying to pull repository docker.io/fedora/ssh ...
2aeb2b6d9705: Download complete
511136ea3c5a: Download complete
00a0c78eeb6d: Download complete
834629358fe2: Download complete
571e8a51403c: Download complete
87d5d42e693c: Download complete
92b5ef05fe68: Download complete
92d3910dc33c: Download complete
cf2e9fa11368: Download complete
Status: Downloaded newer image for docker.io/fedora/ssh:latest
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
docker.io/registry latest 24dd746e9b9f 3 days ago 413.8 MB
docker.io/fedora/ssh latest 2aeb2b6d9705 9 days ago 254.4 MB
6、创建镜像链接或为基础镜像打个标签
[root@localhost ~]# docker tag docker.io/fedora/ssh 127.0.0.1:5000/ssh
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
docker.io/registry latest 24dd746e9b9f 3 days ago 413.8 MB
docker.io/fedora/ssh latest 2aeb2b6d9705 9 days ago 254.4 MB
127.0.0.1:5000/ssh latest 2aeb2b6d9705 9 days ago 254.4 MB
7、修改Docker配置文件制定私有仓库url
[root@localhost ~]# vim /etc/sysconfig/docker
修改此行
OPTIONS='--selinux-enabled --insecure-registry 192.168.0.109:5000'
[root@localhost ~]# service docker restart
Redirecting to /bin/systemctl restart docker.service
8、提交镜像到本地私有仓库中
[root@localhost ~]# docker push 127.0.0.1:5000/ssh
The push refers to a repository [127.0.0.1:5000/ssh] (len: 1)
Sending image list
Pushing repository 127.0.0.1:5000/ssh (1 tags)
511136ea3c5a: Image successfully pushed
00a0c78eeb6d: Image successfully pushed
834629358fe2: Image successfully pushed
571e8a51403c: Image successfully pushed
87d5d42e693c: Image successfully pushed
92b5ef05fe68: Image successfully pushed
92d3910dc33c: Image successfully pushed
cf2e9fa11368: Image successfully pushed
2aeb2b6d9705: Image successfully pushed
Pushing tag for rev [2aeb2b6d9705] on {http://127.0.0.1:5000/v1/repositories/ssh/tags/latest}
9、查看私有仓库是否存在对应的镜像
[root@localhost ~]# curl 127.0.0.1:5000/v1/search
{"num_results": 1, "query": "", "results": [{"description": "", "name": "library/ssh"}]}
10、查看镜像的存储目录和文件
[root@localhost ~]# tree /opt/data/registry/repositories/
/opt/data/registry/repositories/
└── library
└── ssh
├── _index_images
├── json
├── tag_latest
└── taglatest_json

2 directories, 4 files
三、从私有仓库中下载已有的镜像
1、登陆另外一台Docker客户端
[root@localhost ~]# ssh root@192.168.0.110
The authenticity of host '192.168.0.110 (192.168.0.110)' can't be established.
ECDSA key fingerprint is 5b:81:4b:66:d6:dd:48:16:9f:85:58:72:21:bd:ba:39.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.110' (ECDSA) to the list of known hosts.
root@192.168.0.110's password:
Last login: Sun Apr 26 14:39:51 2015 from 192.168.0.103
2、修改Docker配置文件
[root@localhost ~]# vim /etc/sysconfig/docker
修改此行
OPTIONS='--selinux-enabled --insecure-registry 192.168.0.109:5000' //添加私有仓库地址
[root@localhost ~]# service docker restart
Redirecting to /bin/systemctl restart docker.service
3、从私有仓库中下载已有的镜像
[root@localhost ~]# docker pull 192.168.0.109:5000/ssh
Trying to pull repository 192.168.0.109:5000/ssh ...
2aeb2b6d9705: Download complete
511136ea3c5a: Download complete
00a0c78eeb6d: Download complete
834629358fe2: Download complete
571e8a51403c: Download complete
87d5d42e693c: Download complete
92b5ef05fe68: Download complete
92d3910dc33c: Download complete
cf2e9fa11368: Download complete
Status: Downloaded newer image for 192.168.0.109:5000/ssh:latest
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
192.168.0.109:5000/ssh latest 2aeb2b6d9705 9 days ago 254.4 MB
四、浏览器访问仓库

centos7 docker私有仓库搭建的更多相关文章

  1. CentOS7 Docker私有仓库搭建及删除镜像 【转】

    文章来源:centos7 Docker私有仓库搭建及删除镜像 如果不想用私有镜像库,你可以用docker的库 https://hub.docker.com 环境准备 环境:两个装有Docker 17. ...

  2. centos7 Docker私有仓库搭建及删除镜像

    如果不想用私有镜像库,你可以用docker的库 https://hub.docker.com 环境准备 环境:两个装有Docker 17.09.0-ce 的centos7虚拟机 虚拟机一:192.16 ...

  3. Docker学习笔记 — Docker私有仓库搭建

    Docker学习笔记 — Docker私有仓库搭建   目录(?)[-] 环境准备 搭建私有仓库 测试 管理仓库中的镜像 查询 删除 Registry V2   和Mavan的管理一样,Dockers ...

  4. docker私有仓库搭建(ubuntu 14.04和centos7)

    最近是在做一个关于docker云化的项目,马上就要开始实战.下午先做了一个私有仓库搭建的实验,先大概做个笔记,有兴趣的蛮看一下吧. 先在所有机子上都安装上docker,我的是两台ubuntu,分别是1 ...

  5. Docker学习笔记 — Docker私有仓库搭建【转载】

    标签: Docker 2015-03-10 21:08 24190人阅读 评论(0) 收藏 举报  分类: Docker(26)    目录(?)[+]   和Mavan的管理一样,Dockers不仅 ...

  6. CentOS环境下Docker私有仓库搭建

    本文讲述如何搭建docker私有仓库. 有了docker hub,为什么还要搭建docker私有仓库? 1.性能考虑:docker hub的访问要通过互联网,性能太低. 2.安全性:更多的时候,镜像不 ...

  7. docker私有仓库搭建和资源限制

    Docker 私有仓库的搭建 docker 私有仓库默认只支持https协议的访问  不支持http协议 如果需要允许通过http协议访问 必须手动修改配置文件 docker官方默认提供的仓库  提供 ...

  8. docker私有仓库搭建及认证

    什么是docker? Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化.容器是完全使用沙箱机 ...

  9. docker探索-docker私有仓库搭建(九)

    前言 本文讲解搭建docker的私有仓库,和Mavan的管理一样,Dockers不仅提供了一个中央仓库,同时也允许我们使用registry搭建本地私有仓库 一.环境 ip 主机名 操作系统 角色 19 ...

随机推荐

  1. 代码改变世界 | 如何封装一个简单的 Koa

    下面给大家带来:封装一个简单的 Koa Koa 是基于 Node.js 平台的下一代 web 开发框架 Koa 是一个新的 web 框架,可以快速而愉快地编写服务端应用程序,本文将跟大家一起学习:封装 ...

  2. centos6.6安装hadoop-2.5.0(二、伪分布式部署)

    操作系统:centos6.6(一台服务器) 环境:selinux disabled:iptables off:java 1.8.0_131 安装包:hadoop-2.5.0.tar.gz 伪分布式环境 ...

  3. ios 汽车品牌展示案例

    汽车组模型 // ZQRGroup.h #import <Foundation/Foundation.h> @interface ZQRGroup : NSObject /** *组标题 ...

  4. win10---cmd终端下连接ubantu--SSH SERVER服务

    在win10 cmd终端下输入 SSH  ubantu@192.168.124.134 之后输入yes 在输入yes

  5. mysql主从复制-读写分离-原理

    Mysql主从复制和读写分离 在实际的生产环境中,如果对mysql数据库的读和写都在一台数据库服务器中操作,无论是在安全性.高可用性,还是高并发等各个方面都是不能满足实际需求的.因此,一般通过主从复制 ...

  6. Python用户交互

    print("开始") # 赋值,把等号右边的内容赋值给左边 s = input() #input("这里是input")# input输入,让用户输入一些内容 ...

  7. python3:logging模块 输出日志到文件

    python自动化测试脚本运行后,想要将日志保存到某个特定文件,使用python的logging模块实现 参考代码: import logging def initLogging(logFilenam ...

  8. Web服务器使用基于纯文本表单的身份验证——.net(未完待续)

    asp.net 表单验证方式 Asp.net的身份验证有有三种,分别是"Windows | Forms| Passport",其中又以Forms验证用的最多,也最灵活. 根据实际需 ...

  9. [转]自然语言处理中的Attention Model:是什么及为什么

    自然语言处理中的Attention Model:是什么及为什么 https://blog.csdn.net/malefactor/article/details/50550211 /* 版权声明:可以 ...

  10. Kesci: Keras 实现 LSTM——时间序列预测

    博主之前参与的一个科研项目是用 LSTM 结合 Attention 机制依据作物生长期内气象环境因素预测作物产量.本篇博客将介绍如何用 keras 深度学习的框架搭建 LSTM 模型对时间序列做预测. ...