`

搭建docker私有仓库registry

阅读更多
1、操作系统
ubuntu 14.04 x64

2、安装docker & docker-compose
2.1.安装docker
http://www.widuu.com/chinese_docker/installation/ubuntu.html#Ubuntu安装Docker
$ sudo apt-get update
$ sudo apt-get install linux-image-generic-lts-trusty
$ sudo reboot
$ wget -qO- https://get.docker.com/ | sh
$ sudo docker -v

#Create the docker group 可做可不做
$ sudo groupadd docker

#Add your user to docker group
$ sudo usermod -aG docker ubuntu(用户名)

注:提示docker版本如“Docker version 1.11.1, build 20f81dd”则安装成功

2.2.安装docker-compose
https://docs.docker.com/compose/install/
$ which curl
# apt-get install curl -y 

# apt-get install python-pip python-dev -y
# pip install -U docker-compose  
# docker-compose --v

注:提示docker-compose版本如“docker-compose version 1.7.1, build 6c29830”则安装成功

3、搭建registry私库
创建数据和证书目录
$ sudo mkdir -p /opt/docker/registry/data
$ sudo mkdir -p /opt/docker/registry/certs

Docker的私有Registry要求使用https访问。需要生成ssl证书。
$ cd /opt/docker/registry/

验证是否安装了openssl
$ which openssl

如果已安装则显示openssl所在路径,没安装则什么也不显示
$ sudo apt-get install openssl libssl-dev (libssl-dev:openssl开发库)

创建密码文件
$ openssl genrsa -out registry_tomhat_com.key 2048

生成密钥
$ openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/registry_tomhat_com.key -x509 -days 365 -out certs/registry_tomhat_com.crt

下面是输出,需要填写一些信息:
Generating a 4096 bit RSA private key
........................................++
..........................................++
writing new private key to 'certs/registry_tomhat_com.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:BeiJing
Locality Name (eg, city) []:BeiJing
Organization Name (eg, company) [Internet Widgits Pty Ltd]:ChinaOPS
Organizational Unit Name (eg, section) []:ChinaOPS
Common Name (e.g. server FQDN or YOUR name) []:registry.tomhat.com
Email Address []:
注意:上面提示里的Common Name必须要添写完整域名
使用编辑器编辑 /opt/docker/registry/docker-compose.yml,内容如下:
(docker/registry为源文档的docker_registry)
registry:
    container_name : tomhat_registry
    restart : always
    image : registry:2
    ports:
        - 443:5000
    environment:
        REGISTRY_HTTP_TLS_CERTIFICATE: /certs/registry_tomhat_com.crt
        REGISTRY_HTTP_TLS_KEY: /certs/registry_tomhat_com.key
    volumes:
        - /opt/docker/registry/data:/var/lib/registry
        - /opt/docker/registry/certs:/certs


使用docker-compose启动registry容器。
# docker-compose up -d

注意:用root用户执行命令在docker-compose.yml所在目录

如下是正确提示
Pulling registry (registry:2)...
2: Pulling from library/registry
efd26ecc9548: Pull complete
a3ed95caeb02: Pull complete
39091a8d8094: Pull complete
c5ad04c01f33: Pull complete
e441cc69d374: Pull complete
Digest: sha256:5206f99cc4d06dedc6d291324935ef134001f30fe05bf47e8d0b58d7e93e3843
Status: Downloaded newer image for registry:2
Creating cops_registry


# docker pull  registry.ecloud.com.cn/tomcat
# docker tag 660259e51042 registry.tomhat.com/tomcat
# cp /opt/docker/registry/certs/registry_tomhat_com.crt /etc/docker/certs.d/regist.tomhat.com/
# echo '127.0.0.1 registry.tomhat.com' > /etc/hosts
# service docker restart
# docker push registry.tomhat.com/tomcat

访问:https://registry.tomhat.com/v2/_catalog
分享到:
评论

相关推荐

    docker私有仓库搭建

    centos7搭建任意版本的docker以及建立自己的私有仓库registry,已实践!

    Docker私有仓库Registry部署的实现

    主要介绍了Docker私有仓库Registry部署的实现,私有仓库最常用的就是Registry、Harbor两种,本文详细介绍如何搭建registry私有仓库,感兴趣的可以了解一下

    Docker搭建私有镜像仓库的方法

    和Mavan的管理一样,Dockers不仅提供了一个中央仓库,同时也允许我们使用registry搭建本地私有仓库。 使用私有仓库有许多优点: 节省网络带宽,针对于每个镜像不用每个人都去中央仓库上面去下载,只需要从私有仓库...

    详解Docker私有仓库Registry的搭建验证

    主要介绍了详解Docker私有仓库Registry的搭建验证,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

    Harbor 搭建 Docker 私有镜像

    harbor是构建企业级私有docker镜像的仓库的开源解决方案,它是 Docker Registry的更高级封装,它除了提供友好的Web UI界面,角色和用户权限管理,用户操作审计等功能外,它还整合了K8s的插件(Add-ons)仓 库,即Helm...

    详解docker私有仓库搭建与使用实战

    hub.docker.com上可以保存镜像,但是网速相对较慢,在内部环境中搭建一个...docker私有仓库服务器 docker-app 192.168.119.155 运行docker服务的普通服务器 准备机器 本次实战中,上述两台机器是vmware上创建的两

    centos7下安装Docker及私有仓库registry服务器安装.pdf

    centos7下安装docker和私有仓库,在自己单位搭建完成,以此为例,给大家借鉴。

    docker 查询或获取私有仓库(registry)中的镜像的方法

    docker 查询或获取私有仓库(registry)中的镜像,使用 docker search 192.168.1.8:5000 命令经测试不好使。 解决: 1、获取仓库类的镜像: [root@shanghai docker]# curl -XGEThttp://192.168.1.8:5000/v2/_...

    Docker搭建私有仓库(registry与Harbor)的实现

    主要介绍了Docker搭建私有仓库(registry与Harbor)的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

    Docker Registry搭建私有镜像仓库的实现方法

    微服务的镜像会上传到Docker仓库保存,常用的公网Docker仓库有阿里云,网易云等,在企业局域网也可以搭建自己的Docker私有仓库,本教程使用Docker提供的私有仓库registry。 1.拉取私有仓库镜像 docker pull ...

    Docker 私有仓库恢复实例详解

    Docker 私有仓库恢复 之前openstack平台由于停电等影响,导致之前制作的registry 私有仓库的主机挂掉,还好数据挂载在nfs中,然后现在尝试重新启动恢复。 虚机安装nfs服务 apt-get install -y nfs-common 编辑 /etc...

    详解CentOS 7 : Docker私有仓库搭建和使用

    搭建私有仓库 179上下载registry镜像 docker pull registry 防火墙添加运行5000端口 iptables -I INPUT 1 -p tcp --dport 5000 -j ACCEPT 下载完之后我们通过该镜像启动一个容器 代码如下: docker run -d -p 500

    Docker Registry 私有仓库搭建详细步骤

    Docker Registry 私有仓库搭建 官方已经提供了很多版本的 Linux 镜像,直接从官方仓库(Public Repositories)下载就可以了。如果考虑到安全性和速度,我们可能会想在自己局域网里架设一个私有仓库(Private ...

    docker 私有化部署

    搭建官方私有仓库 docker pull registry:2 docker run -d -p 5000:5000 registry:2 docker tag zookeeper:3.5 localhost:5000/zookeeper:3.5 docker push localhost:5000/zookeeper:3.5 搭建harbor1.2.2私有...

    Docker私有仓库管理和删除本地仓库中的镜像

    一:Docker私有仓库安装 1、 下载镜像是有镜像仓库: [root@localhost ~]# systemctl start docker #如果已经有镜像了,强制删除原来的镜像的方式如下: [root@xxx-pub /]# docker rmi -f docker.io/registry ...

    Docker 搭建私有仓库(registry、harbor)

    主要介绍了Docker 搭建私有仓库(registry、harbor),小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

Global site tag (gtag.js) - Google Analytics