docker harbor安装使用:nginx
https://github.com/goharbor/harbor/releasesgit
有离线安装和在线安装两种方式github
安装:docker
一、下载安装包数据库
https://github.com/goharbor/harbor/releasesjson
在线安装包,体积小:vim
wget https://storage.googleapis.com/harbor-releases/release-1.8.0/harbor-online-installer-v1.8.1.tgzcentos
离线安装包,体积大:api
wget https://storage.googleapis.com/harbor-releases/release-1.8.0/harbor-offline-installer-v1.8.1.tgz安全
二、修改配置文件
tar -xvf harbor-online-installer-v1.8.1.tgz
cd harbor/
vim harbor.yml
hostname: 118.xxx.xxx.xxx #主机名,能够是域名和IP
port: 80 #访问端口,作了ssl域名正式能够设置成443
harbor_admin_password: Harbor12345 #harbor页面等登陆密码
database:
password: root123 #数据库密码
data_volume: /data #数据卷的路径,是本机的真实路径
三、下载docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
四、执行安装脚本
./install.sh
五、登陆harbor界面
用户名:admin
密码:Harbor12345
六、启动和中止harbor
cd harbor#启动和中止harbor须要找docker-compose.yml文件,因此必须进入harbor安装目或者-f指定harbor项目的docker-compose.yml
docker-compose start/stop
七、推送镜像
docker tag SOURCE_IMAGE[:TAG] 118.xxx.xxx.xxx/myproject/IMAGE[:TAG] #打标签
docker push 118.xxx.xxx.xxx/myproject/IMAGE[:TAG] #推送
推送执行时报错:
1) The push refers to repository 118.xxx.xxx.xxx/myproject/nginx]
Get https://118.xxx.xxx.xxx/v2/: dial tcp 118.xxx.xxx.xxx:443: connect: connection refused
这是由于默认状况下访问的是443端口,须要证书认证,咱们没有,须要在配置文件中添加仓库安全地址
[root@VM_0_3_centos harbor]# cat /etc/docker/daemon.json
{"registry-mirrors": ["http://f1361db2.m.daocloud.io"],
"insecure-registries": ["118.xxx.xxx.xxx"]
}
2) The push refers to repository [118.xxx.xxx.xxx/myproject/nginx]
d7acf794921f: Preparing
d9569ca04881: Preparing
cf5b3c6798f7: Preparing
denied: requested access to the resource is denied
由于咱们建立的项目是私有项目,须要登陆以后才能上传镜像
[root@VM_0_3_centos ~]# docker login 118.xxx.xxx.xxx
Username: admin
Password:#若是没有改动过,admin密码是Harbor12345,也能够在harbor上为项目建立一个用户
3) docker login发生错误
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
须要给docker添加dns配置
[root@VM_0_3_centos harbor]# cat /etc/docker/daemon.json
{"registry-mirrors": ["http://f1361db2.m.daocloud.io"],
"insecure-registries": ["118.xxx.xxx.xxx"],
"dns":["8.8.8.8","114.114.114.114"]
}