阿里云服务器:

127.0.0.1(客户端)

127.0.0.2(私有服务器)

127.0.0.2作为私有仓库使用

1.下载镜像

[root@insure ~]# docker pull registry
Using default tag: latest
latest: Pulling from library/registry
456f9d0bf1d1: Pull complete
b7f3f37a05d2: Pull complete
d1b2fc1a6bc7: Pull complete
400c20544fd6: Pull complete
48473a72399c: Pull complete
Digest: sha256:2a5b47a613fd7e9d28120fa77016554c3dffa8913b6a314ede518447ddc68e2f
Status: Downloaded newer image for registry:latest

2.通过镜像启动一个容器

[root@insure ~]# docker run -d -p : -v /opt/data/registry:/tmp/registry registry
223608fc9814b1c7f22b47248d6006f50f322f35c4f8e92c7a9429a9f6104767
[root@insure ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
223608fc9814 registry "/entrypoint.sh /etc…" seconds ago Up seconds 0.0.0.0:->/tcp eager_euler

命令解析:docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry registry

使用官方提供的registry镜像来搭建一套本地的私有仓库环境

通过-v参数将镜像文件存放到本地的指定路径上/opt/data/registry
本地仓库本身就是容器,命令的含义就是下载并创建一个registry容器,创建本地的私有仓库,仓库得路径是/tmp/registry

进入容器内部的命令

[root@insure ~]# docker exec -it 223608fc9814 sh
/ # ls
bin entrypoint.sh home linuxrc mnt root sbin sys usr
dev etc lib media proc run srv tmp var

127.0.0.1客户端使用

1.下载一个hello-world镜像

[root@insure ~]# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Status: Downloaded newer image for hello-world:latest

2.给hello-world镜像打个tag,表示新的版本

[root@insure ~]# docker tag hello-world:latest 127.0.0.2:/hello-world:latest

3.将新的hello-world镜像上传到私有仓库

[root@insure ~]# docker push 127.0.0.2:/hello-world:latest
The push refers to repository [127.0.0.2:/hello-world]
Get https://127.0.0.2:5000/v2/: http: server gave HTTP response to HTTPS client

原因是docker私有仓库服务器,默认是基于https传输的,所以我们需要在客户端192.168.1.160做相关设置,不使用https传输

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

添加如下内容

{
"registry-mirror": [
"https://registry.docker-cn.com"
],
"insecure-registries": [
"127.0.0.2:5000"
]
}
[root@insure /]# vi /lib/systemd/system/docker.service        修改有问题不用管这个
添加如下内容ExecStart=/usr/bin/dockerd --insecure-registry 116.62.163.101:5000

依次执行下面两条命令,重新启动docker

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

再次执行上传到私有仓库的命令,并测试

[root@insure ~]# docker push 127.0.0.2:/hello-world:latest
The push refers to repository [127.0.0.2:/hello-world]
428c97da766c: Pushed
latest: digest: sha256:1a6fd470b9ce10849be79e99529a88371dff60c60aab424c077007f6979b4812 size:
[root@insure ~]# curl http://127.0.0.2:5000/v2/_catalog
{"repositories":["hello-world"]}

删除镜像进行重新下载

[root@insure /]# docker pull 127.0.0.2:/hello-world
Using default tag: latest
latest: Pulling from hello-world
d1725b59e92d: Pull complete
Digest: sha256:1a6fd470b9ce10849be79e99529a88371dff60c60aab424c077007f6979b4812
Status: Downloaded newer image for 127.0.0.2:/hello-world:latest
[root@insure /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
dashboard latest 60ff0c365e46 days ago 662MB
jdk-8u141 c717428b1276 days ago 578MB
tomcat latest ef802ca71927 days ago 475MB
centos latest 1e1148e4cc2c weeks ago 202MB
openjdk latest 8e7eacedab93 weeks ago 986MB
127.0.0.2:/hello-world latest 4ab4c602aa5e months ago .84kB

127.0.0.2私有仓库上面查看上传的镜像

挂载和临时目录都没有找到,查询

[root@insure lib]# find / -name "hello-world"
/var/lib/docker/volumes/6fcff317934d3c3f4bbaf1c3c4b6dc240b42b69242d8159e75e283ff2d217e16/_data/docker/registry/v2/repositories/hello-world
/var/lib/docker/volumes/efed8eab2f8e536123f218486a9462d41e70bc0c6bb4c019d1b73cf646c878de/_data/docker/registry/v2/repositories/hello-world
[root@insure lib]# cd /var/lib/docker/volumes/efed8eab2f8e536123f218486a9462d41e70bc0c6bb4c019d1b73cf646c878de/_data/docker/registry/v2/repositories
[root@insure repositories]# ls
hello-world
[root@insure repositories]# ls
dashboard hello-world

成功完成私有仓库的创建、客户端镜像的上传和下载。

说明:客户端和私有仓库在不同机器的同一个局域网之内,所用IP都是实际IP,非映射之后的IP。

官方地址 https://yeasy.gitbooks.io/docker_practice/repository/registry.html#%E5%AE%89%E8%A3%85%E8%BF%90%E8%A1%8C-docker-registry

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

  1. Docker仓库搭建(Registry + Portus)

    1.更新系统: yum update -y 2. 安装docker-compos yum -y install epel-release    #pip安装包在epel源中   yum -y inst ...

  2. docker 入门第一步

    docker 安装 利用yum 安装 yum 源更新到最新版本,命令: yum update 需要安装工具 net-tools 命令:yum  install -y net-tools 配置docke ...

  3. Docker 基础篇 入门篇

    1.Docker入门 1.为什么要用docker? 相比于传统: 部署非常慢 成本非常高 资源浪费 难于迁移和扩展 可能会被限定硬件厂商 由于物理机的诸多问题,后来出现了虚拟机 一个物理机可以部署多个 ...

  4. Harbor 使用 Helm 一键安装

    安装 Harbor Harbor 支持多种安装方式,源码目录下面默认有一个安装脚本(make/install.sh),采用 docker-compose 的形式运行 Harbor 各个组件,和前面的课 ...

  5. swarm docker-compose.yml NFS 搭建LNMP

    列表: 172.16.0.40     (swarm-master) 172.16.0.160     (swarm-worker) 172.16.0.170     (swarm-worker) 1 ...

  6. Kubernetes DevOps: Harbor

    Harbor 是一个 CNCF 基金会托管的开源的可信的云原生 docker registry 项目,可以用于存储.签名.扫描镜像内容,Harbor 通过添加一些常用的功能如安全性.身份权限管理等来扩 ...

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

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

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

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

  9. docker资料---仓库搭建

    以下步骤均为本人亲自踩坑,历经数次失败,最终搭建成功 一.环境信息: 操作系统:CentOS 7 Docker版本:1.12.5 (更高版本应该类似) registry:2.4.1 registry- ...

随机推荐

  1. 【操作系统】二、JVM线程与Linux内核线程的映射

    Linux从内核2.6开始使用NPTL (Native POSIX Thread Library)支持,但这时线程本质上还轻量级进程. Java里的线程是由JVM来管理的,它如何对应到操作系统的线程是 ...

  2. Python全栈学习_day011作业

    1,写函数,传入n个数,返回字典{‘max’:最大值,’min’:最小值}例如:min_max(2,5,7,8,4) 返回:{‘max’:8,’min’:2}(此题用到max(),min()内置函数) ...

  3. linux学习笔记-安装配置使用clamav杀毒软件

    我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! 1.安装clamav 2.更新病毒库 # freshclam 如果更新不了,或者更新特别慢,可以手动下载病毒库文件,放到/var ...

  4. ORM&MySQL

    概念: ORM:对象关系映射 , 全拼 Object-Relation Mapping ,是一种为了解决面向对象与关系数据库存在的互不匹配现象的技术.主要实现模型对象到关系型数据库数据的映射.比如:把 ...

  5. FullCalendar:eventColor,eventBackgroundColor, eventBorderColor, and eventTextColor

    <!DOCTYPE html> <html> <head> <meta charset='utf-8' /> <title>背景色設定< ...

  6. imooc《JavaScript深入浅出》上的一个 arraysSimilar 函数

    任务 请在 index.html 文件中,编写 arraysSimilar 函数,实现判断传入的两个数组是否相似.具体需求: 数组中的成员类型相同,顺序可以不同.例如 [1, true] 与 [fal ...

  7. js 复制文本到粘贴板

    //html 在iOS Safari中,剪贴板API有一些限制(实际上是安全措施):   于安全原因,iOS Safari只允许容器中的document.execCommand('copy')文本co ...

  8. 从零自学Java-10.充分利用现有对象

    1.超类和子类的设计:2.建立继承层次:3.覆盖方法. 程序StringLister:使用数组列表和特殊的for循环将一系列字符串按字母顺序显示到屏幕上.这些字符串来自一个数组和命令行参数 packa ...

  9. 安装SQL 2005 出现警告 ,32位ASP.NET已经注册,需要注册64位

    将64位.net注册到iis上 cscript C:\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 ...

  10. 免费ARP

    1. 免费ARP基本概念 免费ARP,也叫Gratutious ARP.无故ARP.这种ARP不同于一般的ARP请求,它的Sender IP和Target IP字段是相同的,相当于是请求自己的IP地址 ...