#register搭建及使用說(shuō)明
## 1、搭建參考 搭建指導(dǎo)
## 2、使用:由于這個(gè)是個(gè)私有鏡像倉(cāng)庫(kù),所要在其他機(jī)器上使用這個(gè)倉(cāng)庫(kù),需要配置/etc/hosts
```Bash
vim /etc/hosts
172.20.2.93 xxxx.sz.test-portus.com
```
## 3、需要配置dockerd的啟動(dòng)項(xiàng)docker.service文件:
```Bash
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd --insecure-registry=xxxx.test-portus.com
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
```
k8s集群的話需要修改options:
```Bash
/etc/systemd/system/docker.service.d
vim docker-options.conf 添加需要加入的repo
[Service]
Environment="DOCKER_OPTS=--insecure-registry=10.96.0.0/16 --insecure-registry=xxxx.test-portus.com --graph=/var/lib/docker \
--iptables=true"
```
重啟docker服務(wù)
```Bash
systemctl daemon-reload
systemctl restart docker.service
```
## 4、本地push 鏡像,push到xxxx.test-portus.com/public/路徑下;
修改一個(gè)鏡像的tag,使用common-ops賬號(hào)xxxx密碼登陸registry;
```Bash
docker tag busybox:latest xxxx.test-portus.com/public/busybox:test
docker login -ucommon-ops -pxxxx xxxx.test-portus.com
docker push xxxx.test-portus.com/public/busybox:test
刪除
docker rmi xxxx.test-portus.com/public/busybox:test
拉去
docker pull xxxx.test-portus.com/public/busybox:test
```
通過(guò)window可以訪問(wèn)https://xxxx.test-portus.com 頁(yè)面上可以查看到剛剛上傳的鏡像。