安装harbor
-
先安装docker 环境
-
安装docker-compose
curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose docker-compose --version
-
安装harbor 离线下载或者在线
-
$ wget -c https://storage.googleapis.com/harbor-releases/release-1.8.0/harbor-offline-installer-v1.8.2-rc1.tgz $ tar zxvf harbor-offline-installer-v1.8.2-rc1.tgz $ cd harbor 或 wget https://storage.googleapis.com/harbor-releases/release-1.8.0/harbor-online-installer-v1.8.0.tgz
-
修改harbor.yml
-
cat harbor.yml |grep hostname 修改hostname为ip或者域名 #屏蔽掉https #docker horbor harbor_admin_password: Harbor12345 password: root123
-
./prepare 需要准备环境配置初始化
-
./install.sh --with-clair 镜像扫描功能
-
访问:http://192.168.5.103/harbor/sign-in?redirect_url=%2Fharbor%2Fprojects
-
docker-compose start/stop/restart
-
docker-compose up -d ###后台启动,如果容器不存在根据镜像自动创建
docker-compose down -v ###停止容器并删除容器
使用方法
# 使用前先登录
$ docker login 192.168.49.135
Username:
Password:
Login Succeeded
# 上传之前先打tag
docker pull k8s.gcr.io/kubernetes-dashboard
docker tag k8s.gcr.io/kubernetes-dashboard XXX.XXX.XXX.XXX/library/k8s.gcr.io/kubernetes-dashboard
# 上传镜像
docker push 192.168.49.135/nginx/nginx:v1
# 下载镜像
docker pull 192.168.49.135/nginx/nginx:v1
遇到的问题:
原因为:docker默认采用HTTPS,需要连接的时候切换为http
Error response from daemon: Get https://192.168.5.103/v2/: dial tcp 192.168.5.103:443: connect: connection refused
修改 /etc/docker/:
daemon.json
{
"insecure-registries":["192.168.5.103","harbor.honops.com"],
"registry-mirrors": ["https://2kmdn5ce.mirror.aliyuncs.com"]
}
1.注意隐藏文件ls -la (重新安装需要删除,不然会有残留)
2.初始 ./prepare 需要执行环境配置初始化命令
生成证书:
[root@docker-server3 harbor]# mkdir pki
[root@docker-server3 harbor]# cd pki
[root@docker-server3 pki]# openssl genrsa -des3 -out server.key 1024
[root@docker-server3 pki]# openssl rsa -in server.key -out server.key
[root@docker-server3 pki]# openssl req -new -key server.key -out server.csr
[root@docker-server3 pki]# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
[root@docker-server3 pki]# ll
-rw-r--r-- 1 root root 920 Jan 3 03:06 server.crt
-rw-r--r-- 1 root root 684 Jan 3 03:04 server.csr
-rw-r--r-- 1 root root 887 Jan 3 03:03 server.key
推荐参考地址:https://blog.csdn.net/shawn210/article/details/98068165