Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6889039
  • 博文数量: 3857
  • 博客积分: 6409
  • 博客等级: 准将
  • 技术积分: 15948
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-02 16:48
个人简介

迷彩 潜伏 隐蔽 伪装

文章分类

全部博文(3857)

文章存档

2017年(5)

2016年(63)

2015年(927)

2014年(677)

2013年(807)

2012年(1241)

2011年(67)

2010年(7)

2009年(36)

2008年(28)

分类: 虚拟化

2015-04-30 00:14:38

如何部署 Docker Registry 服务

[日期:2015-04-28] 来源:  作者:KevinSJ [字体:  ]

在 Registry 服务器上配置 TLS

在本节中,将在服务器上配置 TLS,使能通过 https 协议来通信。在服务器上启用 TLS 是在企业防火墙内运行 Registry 推荐的最低安全配置。达成这一目标的方法之一就是构建你自己的 Registry 镜像。

 

下载 source 并生成 certificates

1、。

当然,也可以使用 git clone 命令。

2、把下载的包解压到本地目录。

解压后创建 distribution 目录。

3、进入 distribution 目录。

$ cd distribution

4、新建 certs 子目录。

$ mkdir certs

5、使用 SSL 生成自签名证书。

$ openssl req      -newkey rsa:2048 -nodes -keyout certs/domain.key      -x509 -days 365 -out certs/domain.crt

此命令将提示你回答一些基本的信息,用于创建证书。

6、列出 certs 目录的内容。

$ ls certs
domain.crt domain.key

当你构建这个 Container 时,certs 目录及其内容也会自动被复制。

 

将 TLS 加入配置

distribution 软件库在 cmd 子目录中包含有示例 Registry 配置。在本节中,您可以编辑这些配置之一,以添加 TLS 支持。

1、编辑 ./cmd/registry/config.yml 文件。

$ vi ./cmd/registry/config.yml

2、定位到 http 区块。

http:     addr: :5000     secret: asecretforlocaldevelopment
    debug:             addr: localhost:500

3、给服务器的自签名证书新增一个 tls 区块:

http:     addr: :5000     secret: asecretforlocaldevelopment
    debug:             addr: localhost:5001     tls:         certificate: /go/src/github.com/docker/distribution/certs/domain.crt
        key: /go/src/github.com/docker/distribution/certs/domain.key

提供 Container 内到证书的路径。如果你希望跨 Layer 使用两步认证,那么你可以增加一个 clientcas 区块选项。

4、保存并关闭该文件。

 

构建并运行你的 Registry 镜像

1、构建你的 Registry 镜像。

$ docker build -t secure_registry .

2、运行你的新镜像。

$ docker run -5000:5000 registry_local:latest
time="2015-04-12T03:06:18.616502588Z" level=info msg="endpoint local-8082 disabled, skipping" environment=development instance.id=bf33c9dc-2564-406b-97c3-6ee69dc20ec6 service=registry
time="2015-04-12T03:06:18.617012948Z" level=info msg="endpoint local-8083 disabled, skipping" environment=development instance.id=bf33c9dc-2564-406b-97c3-6ee69dc20ec6 service=registry
time="2015-04-12T03:06:18.617190113Z" level=info msg="using inmemory layerinfo cache" environment=development instance.id=bf33c9dc-2564-406b-97c3-6ee69dc20ec6 service=registry
time="2015-04-12T03:06:18.617349067Z" level=info msg="listening on :5000, tls" environment=development instance.id=bf33c9dc-2564-406b-97c3-6ee69dc20ec6 service=registry
time="2015-04-12T03:06:18.628589577Z" level=info msg="debug server listening localhost:5001"2015/04/12 03:06:28 http: TLS handshake error from 172.17.42.1:44261: remote error: unknown certificate authority

观察启动时的信息。你应该可以看到 tls 在运行。

3、使用 curl 验证可以通过 https 连接。

$ curl -v https://localhost:5000* Rebuilt URL to: https://localhost:5000/* Hostname was NOT found in DNS cache *   Trying 127.0.0.1...* Connected to localhost (127.0.0.1) port 5000 (#0)* successfully set certificate verify locations:*   CAfile: none CApath: /etc/ssl/certs * SSLv3, TLS handshake, Client hello (1):* SSLv3, TLS handshake, Server hello (2):* SSLv3, TLS handshake, CERT (11):* SSLv3, TLS alert, Server hello (2):* SSL certificate problem: self signed certificate * Closing connection 0 curl: (60) SSL certificate problem: self signed certificate More details here: http://curl.haxx.se/docs/sslcerts.html
阅读(1185) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~