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- ...
随机推荐
- Js调试中不得不知的Console
在js调试中,大部分的前端人员都是采用console.log()方法来打印出调试的数据,但是很多人都不知道console这个对象有很多很实在的方法,本文就来介绍一下这些方法的使用. 一.console ...
- Harbor api 操作
harbor 的版本为 1.5.2 为 Harbor 配置 swagger 官网参考: https://github.com/goharbor/harbor/blob/v1.5.2/docs/conf ...
- 修改 this 指向
封装函数 f,使 f 的 this 指向指定的对象 function bindThis(f, oTarget) { if(f.bind){ return f.bind(oTarget); }else{ ...
- 【机器学习】激活函数(ReLU, Swish, Maxout)
https://blog.csdn.net/ChenVast/article/details/81382939 神经网络中使用激活函数来加入非线性因素,提高模型的表达能力. ReLU(Rectifie ...
- Salesforce小知识:在简档中设置Visualforce页面的权限
简档(Profile)中的 Visualforce 页面访问权限 在Salesforce中,对于自定义的简档,可以设置"Visualforce 页面访问"的权限. Visualfo ...
- Java并发编程(六)volatile关键字解析
由于volatile关键字是与Java的内存模型有关的,因此在讲述volatile关键之前,我们先来了解一下与内存模型相关的概念和知识. 一.内存模型的相关概念 Java内存模型规定所有的变量都是存在 ...
- RabbitMQ延迟消息学习
准备做一个禁言自动解除的功能,立马想到了订单的超时自动解除,刚好最近在看RabbitMQ的实现,于是想用它实现,查询了相关文档发现确实可以实现,动手编写了这篇短文. 准备工作 1.Erlang安装请参 ...
- [20171110]_allow_read_only_corruption参数.txt
[20171110]_allow_read_only_corruption参数.txt --//昨天在修改查询隐含参数脚本时发现一个参数_allow_read_only_corruption,感觉应该 ...
- CENTOS7 SYSTEMD SERVICE 将自己的程序放入自动启动的系统服务
1. 进入文件夹cd /usr/lib/systemd/system 2. 创建文件somed.service 3. 输入内容.如果是监控类程序,需要输入Type=forking[Unit]Descr ...
- python第五十三天--进程,协程.select.异步I/O...
进程: #!usr/bin/env python #-*-coding:utf-8-*- # Author calmyan import multiprocessing,threading,time ...