安装docker compose
[root@yang opt]# mkdir harbor
[root@yang opt]# curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
[root@yang opt]# chmod +x /usr/local/bin/docker-compose
[root@yang opt]# docker-compose --version
docker-compose version 1.29.2, build 5becea4c
安装harbor
# 进入到harbor文件所在目录
cd /opt/harbor
# 解压harbor文件到/usr/local下
tar -xf harbor-offline-installer-v2.4.3.tgz -C /usr/local/
# 进入harbor目录
[root@yang opt]# cd /usr/local/harbor
[root@yang harbor]# ls
common.sh harbor.v2.4.3.tar.gz harbor.yml.tmpl install.sh LICENSE prepare
# 生成配置文件
[root@yang harbor]# cp harbor.yml.tmpl harbor.yml
# 修改配置
[root@yang harbor]# vim harbor.yml
......
hostname: 43.142.186.116 #设置为Harbor服务器的IP地址或者域名
......
# https related config
#https: #注释https的配置
# https port for harbor, default is 443
# port: 443
# The path of cert and key files for nginx
#certificate: /your/certificate/path
#private_key: /your/private/key/path
......
harbor_admin_password: Harbor12345 #harbor web界面登陆密码
# 配置域名解析
[root@yang harbor]# vim /etc/hosts
云服务器ip reg.harbor.com
# 执行安装harbor脚本
[root@yang harbor]# ./install.sh
......
[Step 5]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating harbor-db ... done
Creating registryctl ... done
Creating harbor-portal ... done
Creating redis ... done
Creating registry ... done
Creating harbor-core ... done
Creating nginx ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.----
# 启动harbor
[root@yang harbor]# cd /usr/local/harbor/
[root@yang harbor]# docker-compose start
Starting log ... done
Starting registry ... done
Starting registryctl ... done
Starting postgresql ... done
Starting portal ... done
Starting redis ... done
Starting core ... done
Starting jobservice ... done
Starting proxy ... done
访问:云服务器ip:80
配置
[root@yang dockerfiles]# vim /etc/docker/daemon.json
{
"registry-mirrors": [
"https://mirror.ccs.tencentyun.com"
],
"insecure-registries": ["43.142.186.116:80"]
}
[root@yang dockerfiles]# systemctl daemon-reload
[root@yang dockerfiles]# systemctl restart docker
[root@yang dockerfiles]# cd /usr/local/harbor/
[root@yang dockerfiles]# ./install.sh
[root@yang dockerfiles]#
[root@yang dockerfiles]# docker build -f dockerfile-test-cmd -t cmd-test:1.0 .
[root@yang dockerfiles]# docker login 43.142.186.116:80
[root@yang dockerfiles]# docker tag cmd-test:1.0 43.142.186.116:80/personal/cmd-test:1.0
[root@yang dockerfiles]# docker push 43.142.186.116:80/personal/cmd-test:1.0
[root@yang dockerfiles]# docker pull 43.142.186.116:80/personal/cmd-test:1.0