使用harbor搭建docker私有仓库
规划:
10.0.0.17 安装 harbor
10.0.0.27 将本地镜像上传到harbor,或者从harbor下载镜像到本地
10.0.0.17上的 操作:
1、安装docker
curl -fsSL https://get.docker.com/ | sh
cat > /etc/docker/daemon.json << EOF
{
"registry-mirrors": ["https://reg-mirror.qiniu.com/"],
"insecure-registries": ["10.0.0.17"]
}
EOF
systemctl daemon-reload && systemctl restart docker && systemctl enable docker
docker -v
2、安装docker-compose
yum install docker-compose -y
docker-compose -v
3、安装harbor
wget https://github.com/goharbor/harbor/releases/download/v2.5.3/harbor-offline-installer-v2.5.3.tgz
tar zxvf harbor-offline-installer-v2.5.3.tgz
cd harbor
docker load -i harbor.v2.5.3.tar.gz
./prepare
cp harbor.yml.tmpl harbor.yml
sed -i.bak -e '/^hostname:/chostname: 10.0.0.17' -e 's/^https/#&/' \
-e 's/port: 443/#&/' -e 's/certificate:/#&/' -e 's/private_key:/#&/' \
-e '/harbor_admin_password:/charbor_admin_password: 123456' harbor.yml
./install.sh
# 浏览器访问 10.0.0.17,输入用户名和密码

# 项目 - 新建项目, 访问级别-公开

# 系统管理- 用户管理 - 创建用户

# 项目 - (具体项目) - “+用户”



10.0.0.27上的 操作:
1、安装docker
curl -fsSL https://get.docker.com/ | sh
cat > /etc/docker/daemon.json << EOF
{
"registry-mirrors": ["https://reg-mirror.qiniu.com/"],
"insecure-registries": ["10.0.0.17"]
}
EOF
systemctl daemon-reload && systemctl restart docker && systemctl enable docker
docker -v
2、登录仓库
docker login 10.0.0.17
3、创建镜像
cat > Dockerfile <<EOF
FROM hub.c.163.com/library/centos
MAINTAINER chen
RUN yum install net-tools -y
CMD ["/bin/bash"]
EOF
docker build -t centos:v1 .
docker tag centos:v1 10.0.0.17/hehe/centos:v1
docker push 10.0.0.17/hehe/centos:v1
刷新harbor页面,查看镜像是否上传成功

在10.0.0.17上,拉取镜像
docker pull 10.0.0.17/hehe/centos:v1
docker images

浙公网安备 33010602011771号