使用Harbor创建docker镜像仓库
作者:互联网
一、为什么使用Harbor
Harbor是开源免费的软件
Harbor是面向企业级用户的
Harbor具有比较友好的WEB管理界面
二、Harbor官方资源
https://github.com/goharbor/harbor/blob/master/docs/installation_guide.md https://github.com/goharbor/harbor/releases
三、前提条件一:安装docker
1. 删除旧版本的docker-ce
# yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
2. 安装依赖包
# yum install -y yum-utils device-mapper-persistent-data lvm2
3. 导入repo仓库
# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
4. 安装docker-ce
# yum install docker-ce docker-ce-cli containerd.io -y
5. 配置阿里云镜像加速(可选)
# vim /etc/docker/daemon.json { "registry-mirrors": ["https://xxxx.mirror.aliyuncs.com"] }
6. 启动docker服务
# systemctl daemon-reload # systemctl start docker # systemctl enable docker
四、前提条件二:安装docker-compose
1. 下载docker-compose可执行文件
# curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
2. 赋予docker-compose可执行权限
# chmod +x /usr/local/bin/docker-compose
3. 测试,查询docker-compose当前版本
# docker-compose --version
五、安装配置Harbor
1. Harbor安装包分为在线安装和离线安装,本次通过在线安装方式安装,先通过Web页面下载在线安装文件然后解压
# tar xvf harbor-online-installer-<version>.tgz
2. 修改harbor.yml配置文件
# vim harbor.yml hostname: 192.168.0.131 # 写主机名或IP地址 http: port: 80 harbor_admin_password: Harbor12345 # UI初始化admin密码,登录后可修改 database: password: root123 data_volume: /data # 数据本地存放位置 log: # 日志配置 level: info rotate_count: 50 rotate_size: 200M location: /var/log/harbor
3. 安装harbor
# ./install.sh ### 会下载以下docker image文件,版本仅做参考 REPOSITORY TAG goharbor/redis-photon v1.8.0 goharbor/harbor-registryctl v1.8.0 goharbor/registry-photon v2.7.1-patch-2819-v1.8.0 goharbor/nginx-photon v1.8.0 goharbor/harbor-log v1.8.0 goharbor/harbor-jobservice v1.8.0 goharbor/harbor-core v1.8.0 goharbor/harbor-portal v1.8.0 goharbor/harbor-db v1.8.0 goharbor/prepare v1.8.0
4. 启动或关闭harbor
# cd /PATH/harbor_install_dir/ # docker-compose start # docker-compose stop # docker-compose ps
5. 修改harbor配置,并重新应用和启动
# docker-compose down -v # vim harbor.yml # ./prepare # docker-compose up -d
6. 彻底删除harbor
# cd /PATH/harbor_install_dir/ # docker-compose down -v # rm -r /data/database # rm -r /data/register
六、Docker客户端配置
1. docker主机添加harbor仓库地址
# vim /etc/docker/daemon.json { "insecure-registries": ["harbor_server_ip:80"] } # systemctl daemon-reload # systemctl restart docker
2. 测试,上传本地镜像到harbor仓库
# docker login harbor_server_ip # docker pull hello-world # docker tag hello-world:latest harbor_server_ip:80/library/hello-world:latest # docker push harbor_server_ip:80/library/hello-world:latest
3. WEB登陆地址和默认用户密码
http:harbor_server_ip Username: admin Password: Harbor12345
标签:compose,goharbor,Harbor,harbor,v1.8,镜像,docker 来源: https://blog.51cto.com/daibaiyang119/2437006