1、下载harbor,地址https://github.com/vmware/harbor
2、进入harbor-master/Deploy目录,修改harbor.cfg文件,主要修改以下信息
2.1、hostname =10.10.20.202 (这个是harbor所在服务器的ip,不能写127.0.0.1)
2.2、修改邮箱相关信息
3、执行./prepare命令
4、修改/usr/lib/systemd/system/docker.service文件,添加--insecure-registry 10.10.20.202
#修改前
#ExecStart=/usr/bin/docker daemon -H fd://
#修改后
ExecStart=/usr/bin/docker daemon --insecure-registry 10.10.20.202 -H fd://
如果不修改这个配置文件,则登录镜像私服时(docker login 10.10.20.202)会抛出如下错误
Error response from daemon: Get https://10.10.20.202/v1/users/: dial tcp 10.10.20.202:443: getsockopt: connection refused
5、build并启动
docker-compose up -d
6、从docker hub上下载hello-world镜像
docker run hello-world
7、给镜像打标签,以便上传到私服,其中library是harbor默认提供的项目
docker tag hello-world 10.10.20.202/library/hello-world
8、上传镜像
登录镜像私服,执行以下指令,再输入用户名和密码
docker login 10.10.20.202
上传镜像
docker push 10.10.20.202/library/hello-world
9、在浏览器上访问10.10.20.202,登录完成后,点击library这个项目,即可看到上传的hello-world
以下附带harbor的启动、停止命令
Build and start Harbor:
$ sudo docker-compose up -d
Creating harbor_log_1
Creating harbor_mysql_1
Creating harbor_registry_1
Creating harbor_ui_1
Creating harbor_proxy_1
Stop Harbor:
$ sudo docker-compose stop
Stopping harbor_proxy_1 ... done
Stopping harbor_ui_1 ... done
Stopping harbor_registry_1 ... done
Stopping harbor_mysql_1 ... done
Stopping harbor_log_1 ... done
Restart Harbor after stopping
$ sudo docker-compose start
Starting harbor_log_1
Starting harbor_mysql_1
Starting harbor_registry_1
Starting harbor_ui_1
Starting harbor_proxy_1
Remove Harbor‘s containers while keeping the image data and Harbor‘s database files on the file system:
$ sudo docker-compose rm
Going to remove harbor_proxy_1, harbor_ui_1, harbor_registry_1, harbor_mysql_1, harbor_log_1
Are you sure? [yN] y
Removing harbor_proxy_1 ... done
Removing harbor_ui_1 ... done
Removing harbor_registry_1 ... done
Removing harbor_mysql_1 ... done
Remove Harbor‘s database and image data (for a clean re-installation):
$ rm -r /data/database
$ rm -r /data/registry