Docker学习记录

Docker学习记录 - 构建私有镜像仓库 - harbor

一、前置条件

安装docker

安装docker-compose

注意:harbor 对 docker 要求版本比较高,请安装最新版本

二、下载 harbor 安装包

download   中 harbor-offline-installer 对应的版本。

三、上传到服务器指定目录并解压,如 /home

tar -zxvf harbor-offline-installer-v1.10.4.tgz

四、安装

1、进去解压后的目录

2、修改配置 harbor.yml

注意:关闭 https 相关配置

3、

运行 ./prepare

运行 ./install.sh

4、docker ps 查看启动情况

五、使用

打开配置的地址:http://xxxxxxxxxxxxxxxxxxxxxxxxx

默认用户名密码 admin/Harbor12345

六、重启

# 重启harbor仓库
# cd 到 harbor的安装目录
cd /usr/local/harbor

# 执行命令
docker-compose stop
docker-compose up -d

七、docker免密登陆私有镜像库

通过创建docker-registry类的secrets,实现类docker login免密。

生成命令:

kubectl --namespace kube-system create secret docker-registry regcred 

--docker-server=<your-registry-server> 

--docker-username=<your-name> 

--docker-password=<your-pword>


--namespace指定命名空间

regcred为secrets名称

问题

1、用其他主机docker login登录Harbor仓库报错

[gitlab-runner@ecs-aece .ssh]$ docker login xx.xx.xx.xxx
Username: admin
Password: 
Error response from daemon: Get https://xx.xx.xx.xxx/v2/: dial tcp xx.xx.xx.xxx:443: connect: connection refused

这里说拒绝连接,因为我是用http部署的harbor,这里是https://进行访问的,所有出现报错

然后解决这个问题其实就在/etc/docker/daemon.json文件下

添加对私有仓库的认证

然后重启 docker

就可以登录了

{ "insecure-registries":["172.17.8.201:8003"] }

 

2、安装时报错

ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule:  (iptables failed: iptables --wait -t nat -I DOCKER -
i br-968a5a462a0b -j RETURN: iptables: No chain/target/match by that name.

原因:

解释:执行docker-compose up -d时出现ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule
原因:防火墙关闭之后需要重启docker服务。

解决办法:重启docker

service docker restart

参考资料

harbor搭建与使用

harbor仓库搭建

Harbor安装配置全过程

Harbor安装

harbor git

harbor release

docker(三):Harbor 1.8.0 仓库的安装和使用

docker-compose 安装及异常处理

docker免密登陆私有镜像库

原文地址:https://www.cnblogs.com/wangwangfei/p/13381789.html