2019独角兽企业重金招聘Python工程师标准>>>
安装docker
安装docker-compose
安装Harbor 1.5.2
- 下载Harbor
https://pan.baidu.com/s/19-gntfgbQZLjoJMajMG3BQ m5cc
-
解压
tar zxf harbor-online-installer-v1.2.0.tgz -C /usr/local/ cd /usr/local/harbor
-
修改配置
vim harbor.cfg
hostname = abc.com
email_server = smtp.qq.com
email_server_port = 25
email_username = [email protected]
email_password =1234567
email_from = abc
email_ssl = false
harbor_admin_password = admin
db_password = admin
clair_db_password = admin
self_registration = off
project_creation_restriction = adminonly
- 修改docker-compose.yml
vim docker-compose.yml
registry:
image: vmware/registry-photon:v2.6.2-v1.5.2
container_name: registry
restart: always
volumes:
- /data/registry:/storage:z
- ./common/config/registry/:/etc/registry/:z
networks:
- harbor
environment:
- GODEBUG=netdns=cgo
ports:
- 5000:5000
proxy:
image: vmware/nginx-photon:v1.5.2
container_name: nginx
restart: always
volumes:
- ./common/config/nginx:/etc/nginx:z
networks:
- harbor
ports:
- 8080:80
- 1443:443
- 14443:4443
- 配置外部nginx
server {
server_name abc.com;
listen 443 ssl;
client_max_body_size 1000m;
ssl_certificate ./cert/abc.pem;
ssl_certificate_key ./cert/abc.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location /v2/ {
proxy_pass http://127.0.0.1:5000/v2/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_request_buffering off;
}
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 80;
server_name abc.com;
client_max_body_size 1000m;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
- Web ui
https://abc.com admin/admin
- 外网访问
docker login abc.com
docker tag busybox abc.com/library/busybox:admin
docker push abc.com/library/busybox:admin
docker pull abc.com/library/busybox:admin
-
内网访问
-
创建/etc/docker/daemon.json
{
"registry-mirrors": [
"https://registry.docker-cn.com"
],
"insecure-registries":["192.168.1.2:8080"]
}
service docker restart
docker login 192.168.1.2:8080
docker tag busybox 192.168.1.2:8080/library/busybox:admin
docker push 192.168.1.2:8080/library/busybox:admin
docker pull 192.168.1.2:8080/library/busybox:admin
遇到问题
- docker login xxx.com
Authenticating with existing credentials... Login did not succeed, error: Error response from daemon: Get https://docker.daoxuehao.com/v2/: error parsing HTTP 404 response body: invalid character '<' looking for beginning of value: "\r\n
404 Not Found
添加 80:端口
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
- docker push
出现 HTTP 405
https://github.com/goharbor/harbor/issues/37
location /v2/ { proxy_pass http://192.168.xxx.xxxx:5000/v2/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_buffering off; proxy_request_buffering off;
} expose port 5000 in harbor Deploy docker-compose.yml
出现 HTTP 413
error parsing HTTP 413 response body: invalid character '<' looking for beginning of value: "\r\n
413 Request Entity Too Large
server {
...
client_max_body_size 20m;
...
}