docker 仓库搭建
阿里云服务器:
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 仓库搭建的更多相关文章
- Docker仓库搭建(Registry + Portus)
1.更新系统: yum update -y 2. 安装docker-compos yum -y install epel-release #pip安装包在epel源中 yum -y inst ...
- docker 入门第一步
docker 安装 利用yum 安装 yum 源更新到最新版本,命令: yum update 需要安装工具 net-tools 命令:yum install -y net-tools 配置docke ...
- Docker 基础篇 入门篇
1.Docker入门 1.为什么要用docker? 相比于传统: 部署非常慢 成本非常高 资源浪费 难于迁移和扩展 可能会被限定硬件厂商 由于物理机的诸多问题,后来出现了虚拟机 一个物理机可以部署多个 ...
- Harbor 使用 Helm 一键安装
安装 Harbor Harbor 支持多种安装方式,源码目录下面默认有一个安装脚本(make/install.sh),采用 docker-compose 的形式运行 Harbor 各个组件,和前面的课 ...
- 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 ...
- Kubernetes DevOps: Harbor
Harbor 是一个 CNCF 基金会托管的开源的可信的云原生 docker registry 项目,可以用于存储.签名.扫描镜像内容,Harbor 通过添加一些常用的功能如安全性.身份权限管理等来扩 ...
- docker私有仓库搭建(ubuntu 14.04和centos7)
最近是在做一个关于docker云化的项目,马上就要开始实战.下午先做了一个私有仓库搭建的实验,先大概做个笔记,有兴趣的蛮看一下吧. 先在所有机子上都安装上docker,我的是两台ubuntu,分别是1 ...
- CentOS7 Docker私有仓库搭建及删除镜像 【转】
文章来源:centos7 Docker私有仓库搭建及删除镜像 如果不想用私有镜像库,你可以用docker的库 https://hub.docker.com 环境准备 环境:两个装有Docker 17. ...
- docker资料---仓库搭建
以下步骤均为本人亲自踩坑,历经数次失败,最终搭建成功 一.环境信息: 操作系统:CentOS 7 Docker版本:1.12.5 (更高版本应该类似) registry:2.4.1 registry- ...
随机推荐
- 【github&&git】3、git图像化界面GUI的使用
GIT学习笔记 一. 基础内容 1.git是一个版本控制软件,与svn类似,特点是分布式管理,不需要中间总的服务器,可以增加很多分支. 2.windows下的git叫msysgit,下载 ...
- 设置div背景透明的CSS样式
div背景透明样式: 样式代码: .alert{filter:alpha(opacity=100); /* IE */ -moz-opacity:1.0; /* Moz + FF */ opacity ...
- 【读书笔记】iOS-访问iPod媒体库
iOS设备内部都有一个iPod媒体库,在这个媒体库中包含了音频和视频文件,它的来源主要是苹果公司的iTunes Store,现在苹果公司的iTunes Store内容很多,但能够下载到iPod媒体库的 ...
- CloudSim源代码学习——云数据中心(Datacenter)
package org.cloudbus.cloudsim; import java.text.DecimalFormat;//十进制 import java.util.ArrayList; impo ...
- 国网SGCC_UAP 反编译.class文件源代码
SGCC_UAP和eclipse操作方式差不多,对于用惯了IDEA和Android Studio的人来说非常不方便,按住Ctrl点击类名不能查看源码. 因为jar包下都是.class文件,所以需要安装 ...
- Android事件总线(四)源码解析otto
前言 上一篇文章中讲到了otto的用法,这一篇我们来讲一下otto的源码.可能有人觉得otto过时了,但是通过源码我们学习的是高手设计otto时的设计理念,这种设计理念是不过时的. otto各个类的作 ...
- JMeter—定时器(八)
参考<全栈性能测试修炼宝典JMeter实战>第六章 JMeter 元件详解中第三节定时器 JMeter中的定时器一般用来设置延迟与同步.定时器的执行优先级高于取样器,在同一作用域下有多个定 ...
- Django知识补充
目录 一.文件上传 二.Models补充 三.Django总结 一.文件上传 1.通过form表单或者通过From类上传 views.py from django.shortcuts import r ...
- apache的php模块讲解以及搭建phpmyadmin管理数据库mysql
1.php php的包名字叫做php-common,其配置文件使用的是ini风格的格式. php的配置文件以分号作为注释,把分号去掉表示启动此片段功能. 在这里我们可以看到php在apache中的模块 ...
- 4.7 Sublime Text3 中配置 Python环境 --之上安装Sublime 3
返回总目录 目录: 1.展示效果: 2.缺优分析: 3.下载Sublime Text3 (一)展示效果: 1.能够交互式编写Python代码: 2.可以编写文件式Python代码: 3.能够自动补齐代 ...