实验环境的配置
1.实验前提
安装docker
二进制文件:docker-compose-Linux-x86_64-1.24.1
Habor安装包:harbor-online-installer-v1.82.0.tgz
2.实验环境配置
(1)安装docker-compose
[root@server3 ~]# mv docker-compose-Linux-x86_64-1.24.1 /usr/local/bin/docker-compose
[root@server3 ~]# cd /usr/local/bin/
[root@server3 bin]# ls
docker-compose
[root@server3 bin]# chmod +x /usr/local/bin/docker-compose ##给与执行权限
[root@server3 bin]# docker-compose -v ##测试是否安装成功,出现版本则成功
docker-compose version 1.24.1, build 4667896b
(2)harbor的安装
[root@server3 ~]# tar zxf harbor-offline-installer-v1.8.0.tgz -C /usr/local/ ##解压到指定目录
[root@server3 ~]# cd /usr/local/harbor/
[root@server3 harbor]# ls
harbor.v1.8.0.tar.gz harbor.yml install.sh LICENSE prepare
[root@server3 harbor]# vim harbor.yml ##更改配置文件
hostname: 172.25.4.113 ##主机名,安装harbor的主机
port: 80 ##端口为443,因为443端口使用时需要配置证书
harbor_admin_password: westos ##harbor的登录密码更改为westos
(3)harbor的启动
[root@server3 harbor]# sh install.sh ##启动脚本,启动时间较长
✔ ----Harbor has been installed and started successfully.----
Now you should be able to visit the admin portal at http://172.25.4.113.
For more details, please visit https://github.com/goharbor/harbor .
启动过程:
检查运行环境—>需要导入的镜像–>运行容器
监测容器运行是否成功
[root@server3 harbor]# docker-compose ps
Name Command State Ports
-------------------------------------------------------------------------------
harbor-core /harbor/start.sh Up (healthy)
harbor-db /entrypoint.sh Up (healthy) 5432/tcp
postgres
harbor-jobservice /harbor/start.sh Up
harbor-log /bin/sh -c Up (healthy) 127.0.0.1:1514->1051
/usr/local/bin/ ... 4/tcp
harbor-portal nginx -g daemon off; Up (healthy) 80/tcp
nginx nginx -g daemon off; Up (healthy) 0.0.0.0:443->80/tcp
redis docker-entrypoint.sh Up 6379/tcp
redis ...
registry /entrypoint.sh Up (healthy) 5000/tcp
/etc/regist ...
registryctl /harbor/start.sh Up (healthy)
3.web界面进行访问
(1)http://172.25.4.113进行访问
(2)上传本地镜像到仓库
web前端界面创建项目
客户端登录设置
[root@server4 harbor]# cd
[root@server4 ~]# docker login 172.25.4.113
Username: admin
Password:
Error response from daemon: Get https://172.25.4.113/v2/: dial tcp 172.25.4.113:443: connect: connection refused ##登录失败,因为habor默认访问443端口,此时更改的端口为80
[root@server4 ~]# vim /etc/docker/daemon.json ##客户端设置
[root@server4 ~]# cat /etc/docker/daemon.json
{
"insecure-registries":["172.25.4.113"] ##指定访问时,采用http服务
}
[root@server4 ~]# systemctl daemon-reload
[root@server4 ~]# systemctl restart docker
[root@server4 ~]# docker login 172.25.4.113
Username: admin
Password:
Error response from daemon: Get http://172.25.4.113/v2/: dial tcp 172.25.4.113:80: connect: connection refused ##重启服务仍登录失败,原因是harbor的启动创建在docker基础上,docker重启过程中harbor关闭,则需要重启habor
[root@server3 harbor]# sh install.sh
[root@server4 ~]# docker login 172.25.4.113
Username: admin
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded ##登录成功
[root@server4 ~]# docker tag game2048 172.25.4.113/lucky-harbor/game2048 ##打标签
[root@server4 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
172.25.4.113/lucky-harbor/game2048 latest 19299002fdbe 2 years ago 55.5MB
game2048 latest 19299002fdbe 2 years ago 55.5MB
[root@server4 ~]# docker push 172.25.4.113/lucky-harbor/game2048 ##上传到仓库
The push refers to repository [172.25.4.113/lucky-harbor/game2048]
88fca8ae768a: Pushed
6d7504772167: Pushed
192e9fad2abc: Pushed
36e9226e74f8: Pushed
011b303988d2: Pushed
latest: digest: sha256:8a34fb9cb168c420604b6e5d32ca6d412cb0d533a826b313b190535c03fe9390 size: 1364
查看上传是否成功
拉取镜像
[root@server4 ~]# docker pull 172.25.4.113/lucky-harbor/game2048 ##拉取成功
Using default tag: latest
latest: Pulling from lucky-harbor/game2048
Digest: sha256:8a34fb9cb168c420604b6e5d32ca6d412cb0d533a826b313b190535c03fe9390
Status: Image is up to date for 172.25.4.113/lucky-harbor/game2048:latest