curl -fsSL "https://get.docker.com/" | sh
systemctl enable --now docker
yum update -y
yum install python-pip
pip install --upgrade setuptools # 可能由于setuptools版本过低报错
pip install docker-compose # 如果报错可以试试 --ignore-installed
wget -P /usr/local/src/ https://storage.googleapis.com/harbor-releases/release-1.7.0/harbor-online-installer-v1.7.5.tgz # 在线安装
# 最新版本请查看https://github.com/goharbor/harbor/releases/
cd /usr/local/src/
tar zxf harbor-online-installer-v1.7.5.tgz -C /usr/local/
cd /usr/local/harbor/
bash install.sh # 使用--with-clair添加镜像漏洞扫描功能
vim /usr/local/harbor/harbor.cfg # harbor配置文件
# 找到以下项目并且修改
hostname = test.com # 修改访问域名,如果使用其它端口,请在后面添加端口号,如test.com:8080
#邮箱配置(根据实际账号配置)
email_server = smtp.qq.com
email_server_port = 465
email_username = test@qq.com
email_password = 123456
email_from = test@qq.com # 经测试发现必须要和email_username相同才可以发邮件
email_ssl = true # 开启ssl保护,使用端口465,关闭使用端口25
#禁止用户注册
self_registration = off
#设置只有管理员可以创建项目
project_creation_restriction = adminonly
#设置管理员密码
harbor_admin_password = 123456
cd /usr/local/harbor/
docker-compose ps # 查看harbor集群容器,安装后已经启动
# ---------- 控制 ----------
# 必须要在/usr/local/harbor/目录下,或者-f指定docker-compose.yml
# 启动Harbor
docker-compose start
# 停止Harbor
docker-comose stop
# 重启Harbor
docker-compose restart
# 移除Harbor
docker-compose down -v # -v 参数移除vloume
# 重新创建并启动
docker-compose up -d
# ---------- 控制 ----------
vim /usr/local/harbor/docker-compose.yml
# 把proxy下的80:80改为8080:80则为使用8080访问harbor
docker-compose stop proxy # proxy其实就是nginx
docker-compose up -d proxy # 重新开启nginx
netstat -lntp # 查看本地打开端口,如果有docker-proxy为8080则修改成功
# 如果有安全组防火墙,记得先放行对应端口
# 由于使用80端口需要备案,harbor页面已经修改为8080端口(注意修改harbor.cfg的hostname后需要重新执行install.sh)
vim /etc/docker/daemon.json
# 添加 "insecure-registries":["test.com:8080"] }
docker login test.com:8080 # 尝试登录
# 编写dockerfile
mkdir ~/test_harbor && cd ~/test_harbor
cat << EOF > Dockerfile
FROM nginx:latest
MAINTAINER test "test@qq.com"
# 配置环境变量
ENV LANG=C.UTF-8 TZ=Asia/Shanghai
EOF
# build镜像
docker build -t test.com:8080/library/nginx:latest .
# push镜像到远程仓库
docker push test.com:8080/library/nginx:latest
# 从远程仓库拉取镜像
docker pull test.com:8080/library/nginx:latest
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有