docker深入1-配置非https的公司私有的registry仓库
docker深入1-配置非https的公司私有的registry仓库1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
一、安装使用docker服务
请参考另一篇文档。
二、使用registry这个image来构建私有仓库
1、拉取image
$ docker pull registry
Pulling repository registry
9a2409206c78: Download complete
428b411c28f0: Download complete
435050075b3f: Download complete
9fd3c8c9af32: Download complete
6d4946999d4f: Download complete
cf73ddbcb12b: Download complete
7cb6f45e653d: Download complete
c624e1a476d0: Download complete
4b087f2af755: Download complete
6940f969b4ed: Download complete
1bc2ae3e600b: Download complete
c35a7b3ee359: Download complete
b4696f4e4d61: Download complete
7413e661f075: Download complete
Status: Downloaded newer image for registry:latest
# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
registry latest 9a2409206c78 31 hours ago 413.9 MB
2、创建目录用于存储images的数据文件:
# mkdir /data/docker/registry -p
3、启动
注1:默认参数启动遇到错误,暂时用环境变量“-e GUNICORN_OPTS=["--preload"]”来规避这个异常;
$ sudo docker run -d -p 5000:5000 -v /data/docker/registry:/tmp/registry -e GUNICORN_OPTS=["--preload"] --name reg4work registry
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7014a9de8765 registry:latest "docker-registry" 4 minutes ago Up 4 seconds 0.0.0.0:5000->5000/tcp reg4work
# docker logs reg4work
16/Jun/2015:05:15:44 +0000 WARNING: Cache storage disabled!
16/Jun/2015:05:15:44 +0000 WARNING: LRU cache disabled!
16/Jun/2015:05:15:44 +0000 DEBUG: Will return docker-registry.drivers.file.Storage
Starting gunicorn 19.1.1
Listening at: http://0.0.0.0:5000 (1)
Using worker: gevent
Booting worker with pid: 17
Booting worker with pid: 18
Booting worker with pid: 19
Booting worker with pid: 20
三、验证
配置域名解析(当然,直接用IP也成):
10.0.200.20 registry.company.com
调整docker服务的启动参数:
$ sudo service docker stop
$ sudo vim /etc/sysconfig/docker
other_args="--dns 10.0.200.20 --insecure-registry registry.company.com:5000"
$ sudo service docker start
通过push一个image来验证
$ docker tag pcnk/base:v2 registry.company.com:5000/jack/centos7base:latest
$ docker images |grep base
registry.company.com:5000/jack/centos7base latest 064aa35dfcef 5 weeks ago 251.3 MB
pcnk/base v2 064aa35dfcef 5 weeks ago 251.3 MB
$ docker push registry.company.com:5000/jack/centos7base:latest
The push refers to a repository (len: 1)
Sending image list
Pushing repository registry.company.com:5000/centos7base (1 tags)
6941bfcbbfca: Image successfully pushed
41459f052977: Image successfully pushed
fd44297e2ddb: Image successfully pushed
751a85a0d00b: Image successfully pushed
19b009f08542: Image successfully pushed
420cb9e73c70: Image successfully pushed
e97f94a79de0: Image successfully pushed
fde06c761bde: Image successfully pushed
dbfae1099999: Image successfully pushed
064aa35dfcef: Image successfully pushed
Pushing tag for rev on {http://registry.company.com:5000/v1/repositories/centos7base/tags/v2}
$ curl registry.company.com:5000/v1/search |python -m json.tool
% Total % Received % XferdAverage Speed Time Time TimeCurrent
DloadUpload Total Spent LeftSpeed
0 96 0 96 0 016751 0 --:--:-- --:--:-- --:--:-- 19200
{
"num_results": 1,
"query": "",
"results": [
{
"description": "",
"name": "jack/centos7base"
}
]
}
页:
[1]