說明
registry v1
沒有提供認(rèn)證,鑒權(quán)的功能,需要自己通過類似nginx
的反向代理來做簡(jiǎn)單的認(rèn)證鑒權(quán)
registry v2
提供了認(rèn)證屎飘、鑒權(quán)的接口,但是需要自己實(shí)現(xiàn)認(rèn)證鑒權(quán)的功能贾费,或者是對(duì)接第三方的認(rèn)證鑒權(quán)
鑒于此钦购,對(duì)接第三方的認(rèn)證鑒權(quán)是比較合適的選擇,而業(yè)界使用比較多的registry
認(rèn)證鑒權(quán)是cesanta/docker_auth
現(xiàn)在基于docker_auth
來搭建docker registry
- 二進(jìn)制形式安裝
- 下載編譯
registry
git clone https://github.com/docker/distribution.git
cd distribution/cmd/registry
go build
- 編輯配置文件
cp sample.yml conf.yml
配置文件如下
version: 0.1
log:
fields:
service: registry
level: debug
storage:
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
tls:
certificate: /path/to/registry/registry.crt
key: /path/to/registry/registry.key
auth:
token:
realm: "https://docker_auth.ip:5001/auth"
service: "Docker registry"
issuer: "Acme auth server"
rootcertbundle: /path/to/docker_auth/server-cert.pem
- 注意:證書要提前規(guī)劃化好
- http 模塊的證書褂萧,是需要放到
docker deamon
配置的信任證書的地方押桃,一般是/etc/docker/cert.d/registry_xx_dome/registry.crt
這樣在執(zhí)行docker login
等命令是,就可以建立tls連接了- auth token 處的證書导犹,是為了
registry
與auth
建立tls
連接用的- 由于
docker deamon
與registry
交互式唱凯,registry
會(huì)把auth
地址返回回來,讓docker deamon
去申請(qǐng)授權(quán)谎痢,所以docker deamon
會(huì)直接與auth
進(jìn)行交互波丰,而建立tls
連接時(shí),需要認(rèn)證簽名auth
證書的證書舶得,
此時(shí)需要把,centos
環(huán)境下爽蝴,需要把注意是沐批,該證書的簽發(fā)證書放到/etc/pki/ca-trust/source/anchors/
下
然后執(zhí)行update-ca-trust systemctl restart docker
- heath 模塊配置去掉纫骑,負(fù)責(zé),
docker deamon
與registry
交互九孩,會(huì)出發(fā)registry
進(jìn)行heath check
導(dǎo)致失敗- log 日志級(jí)別設(shè)置成
debug
會(huì)打印比較詳盡的日志
- 啟動(dòng)
registry
nohup ./registry serve config.yml &
- 下載編譯
docker_auth
git clone https://github.com/cesanta/docker_auth.git
cd auth_server
govendor sync
#添加兩個(gè)常量到main.go中
go build
添加的兩個(gè)常量是
const ( Version = "xx" BuildId = "xx" )
- docker_auth 配置
注意證書配對(duì)
- 啟動(dòng)
docker_auth
nohup ./auth_server ../examples/simple.yml &
7.測(cè)試略