Docker使用Harbor

1、docker 安装 (略)

curl -sSL https://get.daocloud.io/docker | sh
systemctl start docker && systemctl enable docker

2、安装docker-compose

curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version

3、安装harbor

#wget https://storage.googleapis.com/harbor-releases/release-1.5.0/harbor-offline-installer-v1.5.1.tgz
wget https://github.com/goharbor/harbor/releases/download/v1.9.3/harbor-offline-installer-v1.9.3.tgz
tar xf harbor-offline-installer-v1.9.3.tgz
cd harbor
sed -i 's/reg.mydomain.com/192.168.1.136/' harbor.yml  # 192.168.1.136 是我自己的IP地址
bash install.sh

4、访问

docker-compose ps
访问: http://192.168.1.136
默认用户名/密码:admin/Harbor12345

注意: 如果需要 helm charts 的仓库,默认是没有的

docker-compose stop
./install.sh  --with-chartmuseum

客户端如何使用?

docker login -u admin -p Harbor12345 192.168.1.136
	'''
	WARNING! Using --password via the CLI is insecure. Use --password-stdin.
	Error response from daemon: Get https://192.168.1.136/v2/: dial tcp 192.168.1.136:443: connect: connection refused
	'''

# 需要加上一行
sed -i 's#/usr/bin/dockerd#& --insecure-registry=192.168.1.136#' /usr/lib/systemd/system/docker.service  
systemctl daemon-reload && systemctl restart docker

# 再次登录
docker login -u admin -p Harbor12345 192.168.1.136
	···
		~~~
		Login Succeeded
	···

cat >> /etc/docker/daemon.json << EOF
{
        "registry-mirrors": ["http://192.168.1.136:5000"]
}
EOF
systemctl daemon-reload && systemctl restart docker
# 测试上传镜像
docker pull hello-world
docker tag hello-world 172.168.1.249/library/hello-world:v1
docker push 192.168.1.136/library/hello-world:v1
# 查看Harbor是否有 hello-world:v1 版本


# 拉取镜像
docker rmi -f hello-world
docker pull 172.168.1.249/library/hello-world:v1 
docker images

Last updated