## 准备工作

用到的工具, Xshell5, Xftp5, docker.io/registry:latest镜像

关于docker的安装和设置加速, 请参考这篇博文centos7系统下 docker 环境搭建

参考之前的博文, 设置完加速后, 执行docker pull registry命令, 下载docker.io/registry官方镜像

## 启动registry镜像

启动docker.io/registry容器, 如果tag是latest, 可以忽略不写

docker run -d -p : --restart=always --name local_registry docker.io/registry:latest

-d 后台运行
-p 端口映射, 宿主机80端口映射给容器的5000端口
--restart=always 容器意外关闭后, 自动重启 (如果重启docker服务, 带这个参数的, 能自动启动为Up状态, 不带这个的,不会自动启动)
--name 给容器起个名字, 可以根据这个名字去停止/启动/删除容器

## 配置端口开放

```
[root@localhost docker]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success
[root@localhost docker]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: dhcpv6-client ssh
ports:
protocols:
masquerade: no
forward-ports:
sourceports:
icmp-blocks:
rich rules: [root@localhost docker]# firewall-cmd --reload
success
[root@localhost docker]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: dhcpv6-client ssh
ports: 80/tcp
protocols:
masquerade: no
forward-ports:
sourceports:
icmp-blocks:
rich rules:
```

配置端口开放之后, 需要执行firewall-cmd --reload才能生效

## 重命名镜像

[root@localhost docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
repos_local/zookeeper 0.0. bdb481b4f17a days ago 541.5 MB

repos_local/zookeeper 是上篇博文介绍的使用Dockerfile文件创建的镜像, 重命名

docker tag repos_local/zookeeper:0.0. 192.168.199.131/repos_local/zookeeper:latest

docker tag 原镜像名:tag 新镜像名:tag

docker images 查看镜像名称是否更改正确

[root@localhost docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.199.131/repos_local/zookeeper latest bdb481b4f17a days ago 541.5 MB

## 推送镜像

docker push 192.168.199.131/repos_local/zookeeper:latest
如果提示以下错误, 说明没有把搭建的registry加入可信任的列表里面, 如果有https域名或者能创建.crt证书, 那么可以忽略以下步骤

Error response from daemon: invalid registry endpoint https://192.168.199.131/v0/: unable to ping registry endpoint https://192.168.199.131/v0/
v2 ping attempt failed with error: Get https://192.168.199.131/v2/: dial tcp 192.168.199.131:443: no route to host
v1 ping attempt failed with error: Get https://192.168.199.131/v1/_ping: dial tcp 192.168.199.131:443: no route to host. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry 192.168.199.131` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/192.168.199.131/ca.crt

解决方法:

只针对centos7下 Docker version 1.12.5, build 047e51b/1.12.5版本有效, 其它版本没做过测试

vi /etc/sysconfig/docker

注意--insecure-registry 192.168.199.131插入的位置
# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false --insecure-registry 192.168.199.131'
if [ -z "${DOCKER_CERT_PATH}" ]; then
DOCKER_CERT_PATH=/etc/docker
fi

重启docker服务
systemctl restart docker.service

重新执行docker push 192.168.199.131/repos_local/zookeeper:latest , 这次应该就能成功了

## 查看镜像仓库

[root@localhost docker]# curl 192.168.199.131/v2/_catalog
{"repositories":["repos_local/zookeeper"]}
[root@localhost docker]# curl 192.168.199.131/v2/repos_local/zookeeper/tags/list
{"name":"repos_local/zookeeper","tags":["latest"]}

至于镜像的删除, 目前还没找到一个好的解决方法, 如有建议请留言

如需帮助可向我发起QQ聊天发起QQ聊天

友情赞助

如果您喜欢此文,感觉对您工作有帮助,预期领导会给您涨工资,不妨小额赞助一下,让我有动力继续努力。

赞助方式:打开支付宝App,使用“扫一扫”付款,付款码见下图,别忘了付款留言哦!


或使用微信, 不用加好友就能付款

centos7系统下搭建docker本地镜像仓库的更多相关文章

  1. 微服务架构 - 搭建docker本地镜像仓库并提供权限校验及UI界面

    搭建docker本地镜像仓库并提供权限校验及UI界面 docker本地镜像仓库的作用跟maven私服差不多,特别是公司级或者是小组级开发好的docker仓库可以上传到本地镜像仓库中,需要用时,直接从本 ...

  2. 基于 registry 搭建 Docker 私有镜像仓库

    今天主要介绍使用 registry 来搭建 Docker私有镜像仓库,方便在公司内部项目中使用,registry 也是 Docker 官方提供的一个镜像,操作也很简单. dockerhub: http ...

  3. Centos7系统下安装Docker

    1.确定你的Linux系统是Centos7 命令:cat /etc/redhat-release 2.yum安装gcc相关 1.配置好Centos7能上外网. 2.yum -y install gcc ...

  4. centos 7.1搭建docker本地私有仓库返回500错误

    之前有一篇写到在ubuntu14.04系统上安装私有仓库,遇到了两个问题,本次在centos7上遇到了另外一个问题. 安装完仓库并运行registry镜像之后发现push和pull操作都会返回一个50 ...

  5. 搭建docker 私有镜像仓库

    前期准备 服务器:centos 7.3 docker-ce: 18.06.1-ce docker-compose: 1.22.0 docker 安装 首先,更新系统 yum update yum up ...

  6. 使用harborv1.8.0-rc1 搭建docker私有镜像仓库

    概述 搭建一个私有仓库 harbor介绍 harbor是一个开源的docker容器仓库,由下面几个组件组成 + proxy:用来接收docker客户端和浏览器端的请求,并且把请求转发给后端的服务 + ...

  7. 使用Harbor搭建Docker私有镜像仓库

    Harbor介绍:https://goharbor.io/ 前置条件 需要安装了docker和docker-compose 下载Harbor 在harbor下载页(https://github.com ...

  8. Centos7 系统下搭建.NET Core2.0+Nginx+Supervisor+Mysql环境

    好记性不如烂笔头! 一.简介 一直以来,微软只对自家平台提供.NET支持,这样等于让这个“理论上”可以跨平台的框架在Linux和macOS上的支持只能由第三方项目提供(比如Mono .NET).直到微 ...

  9. CentOS7系统下搭建Jenkins环境

    1. 安装JDK yum -y install java 2.安装Ant 添加JPackage源 yum -y install wget wget http://www.jpackage.org/jp ...

随机推荐

  1. 第31月第15天 -fembed-bitcode

    1. 确保打包的时候使用的是fembed-bitcode, 而不是fembed-bitcode-maker fembed-bitcode-maker:只是简单的标记一下在archive出来的二进制中b ...

  2. Spring.Net 入门学习笔记-----one

    一. 基本概念    Spring.Net是一个轻量级的控制反转(Ioc)和面向切面的(Aop)的容器框架: Ioc:控制反转:简单的说就是将创建对象的控制权转交给外部容器(IApplicationC ...

  3. Python 自然语言处理(1)中文分词技术

    中文分词技术 中文自动分词可主要归纳为“规则分词”“统计分词”和“混合分词”,规则分词主要是通过人工设立词库,按照一定方式进行匹配切分,实现简单高效,但对新词很难进行处理,统计分词能够较好应对新词发现 ...

  4. Linux启动activemq失败

    第一种情况: 在网上查找错误,通过./activemq console命令可以查看到activemq启动的错误信息,另外在data/activemq.log文件中可以查看到错误日志. java.io. ...

  5. rethinking imageNet pre-training

    paper url: https://arxiv.org/abs/1811.08883  当在数据量足够和训练iterations足够的情况下,ImageNet pretrain不会对最后的性能有帮 ...

  6. 题解-COCI-2015Norma

    Problem SPOJ-NORMA2 & bzoj3745 题意概要:给定一个正整数序列 \(\{a_i\}\),求 \[\sum_{i=1}^n\sum_{j=i}^n(j-i+1)\mi ...

  7. VMware虚拟机配置内网电脑能访问

    关键字:内网访问虚拟机.内网访问Linux虚拟机.虚拟机访问外部网络 1.vmware虚拟机网络设置为桥接模式 2.虚拟机配置iP地址,以linux系统为示例. 勾选自动连接,选择手动配置ip,然后配 ...

  8. Android运行时权限

    Android 6.0加入了运行时权限这一概念.对于危险权限,应用必须在使用的时候进行申请.可以使用命令行查看危险权限:adb shell pm list permissions -d -g CALE ...

  9. 后端api规范说明文档

    我们此次后端api的实现主要是按照RESTful api规范来设计的,就是符合REST架构下设计api的规范.简单的来说REST结构就是:利用URL定位资源,用HTTP动词(GET,POST,PUT, ...

  10. GraphQL 01--- GraphQL 介绍及资源总结

    作为一位web开发人员,在使用REST API的时候,是否遇到过这样的问题: 1.调用一个API的时候,总是会返回一些不需要的信息. 2. 对于一个资源的调用,如果想获取到更多的信息,可能需要发送多次 ...