阿里云服务器:

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. 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(浙江省赛2015)

      Ace of Aces Time Limit: 2 Seconds      Memory Limit: 65536 KB There is a mysterious organization c ...

  2. Tests for Variances

    In each case, we'll illustrate how to perform the hypothesis tests of this lesson using summarized d ...

  3. Linux常用基本命令:三剑客命令之-awk内置函数用法

    awk的内置函数大致可以分类为算数函数.字符串函数.时间函数.其他函数等 算数函数 最常用的算数函数有rand函数.srand函数.int函数. 可以使用rand函数生成随机数,但是使用rand函数时 ...

  4. SP8093 JZPGYZ - Sevenk Love Oimaster(广义后缀自动机)

    题意 题目链接 Sol 广义后缀自动机板子题..和BZOJ串那个题很像 首先建出询问串的SAM,然后统计一下每个节点被多少个串包含 最后直接拿询问串上去跑就行了 #include<bits/st ...

  5. element UI实现表格中添加开关控制按钮

    我使用的是element ui V1.4.3 如下图是我要实现的效果: <template> <div> <el-button type="text" ...

  6. float清除浮动

    清除浮动: 在非IE浏览器下,当容器的高度为auto,且容器的内容中有浮动(float为left或right)的元素,在这种情况下,容器的高度不能自动伸长以适应内容的高度,使得内容溢出到容器外面而影响 ...

  7. JMeter 配置元件之计数器Counter

    配置元件之计数器Counter   by:授客 QQ:1033553122 测试环境 apache-jmeter-2.13 1.   计数器简介 允许用户创建一个在线程组范围之内都可以被引用的计数器. ...

  8. idea 自动换行

    如下:

  9. (网页)angularjs中的interval定时执行功能(转)

    转载博客园魔豆: 一个例子,用来显示当前实时时间,1秒钟刷新一次: <!DOCTYPE html> <html ng-app="myApp"> <he ...

  10. nodejs在spawn中执行npm报错 [Error: spawn ENOENT]” errors

    描述: 上代码 var ps = require('child_process').spawn("npm", ['install'], { stdio: 'inherit', cw ...