Docker搭建Harbor镜像仓库
程序员文章站
2022-06-03 23:46:02
...
安装docker
docker安装参考文档:http://www.runoob.com/docker/centos-docker-install.html
安装docker-compose
1.下载1.22.0版本的docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
2.对文件赋予权限
sudo chmod +x /usr/local/bin/docker-compose
3.查看是否安装成功
docker-compose -v
Harbor 安装
1.安装包下载
- 在线安装
下载在线安装包:wget wget https://github.com/vmware/harbor/releases/download/v1.1.2/harbor-online-installer-v1.1.2.tgz
解压:tar xvf harbor-online-installer-v1.1.2.tgz
- 离线安装
下载离线安装包:wget https://github.com/vmware/harbor/releases/download/v1.1.2/harbor-offline-installer-v1.1.2.tgz
解压:tar xvf harbor-offline-installer-v1.1.2.tgz
2.更配置文件
- 进入到解压目录查找文件:harbor.cfg
vi harbor.cfg
- harbor.cfg 文件内容
## Configuration file of Harbor
#The IP address or hostname to access admin UI and registry service.
#DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname = reg.mydomain.com
#The protocol for accessing the UI and token/notification service, by default it is http.
#It can be set to https if ssl is enabled on nginx.
ui_url_protocol = http
#The password for the root user of mysql db, change this before any production use.
db_password = root123
#Maximum number of job workers in job service
max_job_workers = 3
#Determine whether or not to generate certificate for the registry's token.
#If the value is on, the prepare script creates new root cert and private key
#for generating token to access the registry. If the value is off the default key/cert will be used.
#This flag also controls the creation of the notary signer's cert.
customize_crt = on
#The path of cert and key files for nginx, they are applied only the protocol is set to https
ssl_cert = /data/cert/server.crt
ssl_cert_key = /data/cert/server.key
#The path of secretkey storage
secretkey_path = /data
#Admiral's url, comment this attribute, or set its value to NA when Harbor is standalone
admiral_url = NA
- 将上述文件中属性:hostname = reg.mydomain.com 地址改为公网ip或域名,注意:不能是localhost或127.0.0.1
启动harbor
- 在当前目录执行 ./install.sh
[Step 0]: checking installation environment ...
Note: docker version: 18.06.1
Note: docker-compose version: 1.22.0
[Step 1]: loading Harbor images ...
Loaded image: vmware/harbor-jobservice:v1.1.2
Loaded image: vmware/nginx:1.11.5-patched
Loaded image: photon:1.0
Loaded image: vmware/notary-photon:server-0.5.0
Loaded image: vmware/notary-photon:signer-0.5.0
Loaded image: vmware/harbor-adminserver:v1.1.2
Loaded image: vmware/harbor-ui:v1.1.2
Loaded image: vmware/harbor-log:v1.1.2
Loaded image: vmware/harbor-db:v1.1.2
Loaded image: vmware/registry:2.6.1-photon
Loaded image: vmware/harbor-notary-db:mariadb-10.1.10
[Step 2]: preparing environment ...
Clearing the configuration file: ./common/config/adminserver/env
Clearing the configuration file: ./common/config/db/env
Clearing the configuration file: ./common/config/nginx/nginx.conf
Clearing the configuration file: ./common/config/registry/root.crt
Clearing the configuration file: ./common/config/registry/config.yml
Clearing the configuration file: ./common/config/ui/private_key.pem
Clearing the configuration file: ./common/config/ui/env
Clearing the configuration file: ./common/config/ui/app.conf
Clearing the configuration file: ./common/config/jobservice/env
Clearing the configuration file: ./common/config/jobservice/app.conf
loaded secret from file: /data/secretkey
Generated configuration file: ./common/config/nginx/nginx.conf
Generated configuration file: ./common/config/adminserver/env
Generated configuration file: ./common/config/ui/env
Generated configuration file: ./common/config/registry/config.yml
Generated configuration file: ./common/config/db/env
Generated configuration file: ./common/config/jobservice/env
Generated configuration file: ./common/config/jobservice/app.conf
Generated configuration file: ./common/config/ui/app.conf
Generated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.
[Step 3]: checking existing instance of Harbor ...
[Step 4]: starting Harbor ...
Creating harbor-log ... done
Creating harbor-db ... done
Creating registry ... done
Creating harbor-adminserver ... done
Creating harbor-ui ... done
Creating harbor-jobservice ... done
Creating nginx ... done
✔ ----Harbor has been installed and started successfully.----
Now you should be able to visit the admin portal at http://140.143.230.20.
For more details, please visit https://github.com/vmware/harbor .
- 查看当前运行的容器 docker ps
[aaa@qq.com_1_184_centos harbor]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e48e04670461 vmware/harbor-jobservice:v1.1.2 "/harbor/harbor_jobs…" About a minute ago Up About a minute harbor-jobservice
07b5c4776d04 vmware/nginx:1.11.5-patched "nginx -g 'daemon of…" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp nginx
4301bd654008 vmware/harbor-ui:v1.1.2 "/harbor/harbor_ui" About a minute ago Up About a minute harbor-ui
acafe9d77158 vmware/registry:2.6.1-photon "/entrypoint.sh serv…" About a minute ago Up About a minute 5000/tcp registry
77c05b39ba5a vmware/harbor-db:v1.1.2 "docker-entrypoint.s…" About a minute ago Up About a minute 3306/tcp harbor-db
03f1936ee774 vmware/harbor-adminserver:v1.1.2 "/harbor/harbor_admi…" About a minute ago Up About a minute harbor-adminserver
28b00f2d9fc3 vmware/harbor-log:v1.1.2 "/bin/sh -c 'crond &…" About a minute ago Up About a minute 127.0.0.1:1514->514/tcp
登录镜像仓库:
- 默认账号:admin
- 默认密码:Harbor12345
- 登录:http://ip/harbor/sign-in