教你如何搭建Docker私有仓库 docker私有仓库搭建( 三 )


Username: admin
Password:
Error response from daemon: login attempt to http://192.20.16.51/v2/ failed with status: 502 Bad Gateway
Harbor-db service 不能正常启动,最后查看postgresql.log 发现下面 message.
| initdb: directory "/var/lib/postgresql/data" exists but is not empty | If you want to create a new database system, either remove or empty | the directory "/var/lib/postgresql/data" or run initdb | with an argument other than "/var/lib/postgresql/data".因为当时/data/datebase 目录下,确实不是empty, 手动改了docker-compose.yml ,然后 docker-compose up -d 重新启动容器,服务正常
postgresql:image: goharbor/harbor-db:v2.0.0container_name: harbor-dbrestart: alwayscap_drop:- ALLcap_add:- CHOWN- DAC_OVERRIDE- SETGID- SETUIDvolumes:- /data/database:/var/lib/postgresql/data:z问题-2- dial tcp xxx.xxx.xxx.xxx:443: connect: connection refused## docker login 192.20.16.51:80Username: adminPassword:Error response from daemon: Get https://192.20.16.51:80/v2/: http: server gave HTTP response to HTTPS client或者Error response from daemon: Get https://192.168.31.107/v2/: dial tcp 192.168.31.107:443: connect: connection refuseddocker1.3.2版本开始默认docker registry使用的是https,·Harbor默认安装使用的是HTTP协议·,所以当执行用docker login、pull、push等命令操作非https的docker regsitry的时就会报错 。
临时解决办法:需要在每一台harbor客户端机器都要设置”insecure-registries” (彻底解决需要启动Harbor HTTPS证书)

  • 如果系统是MacOS,则可以点击“Preference”里面的“Advanced”在“Insecure Registry”里加上hostname (e.g. docker.bksx.com),重启Docker客户端就可以了 。
  • 如果系统是Ubuntu,则修改配置文件/lib/systemd/system/docker.service,修改[Service]下ExecStart参数,增加–insecure-registry hostname (e.g. docker.bksx.com)
  • 如果系统是Centos,可以修改配置/etc/sysconfig/docker,将OPTIONS增加 –insecure-registry hostname (e.g. docker.bksx.com)
如果是新版本的docker在/etc/sysconfig/ 没有docker这个配置文件的情况下 。
#在daemon.json中添加以下参数[[email protected] harbor]# cat /etc/docker/daemon.json{"insecure-registries": ["hostname"]}注意:该文件必须符合 json 规范,否则 Docker 将不能启动 。另外hostname 必须与harbor.cfg 里的hostname 一致 。
添加完了后重新启动 docker:systemctl daemon-reload && systemctl enable docker && systemctl restart docker
登录后,账号信息都保存到本机的~/.docker/config.json
[email protected]:~/gitee/vnote_notebooks$ docker login 192.168.31.107Username: adminPassword: WARNING! Your password will be stored unencrypted in /home/owen/.docker/config.json.Configure a credential helper to remove this warning. Seehttps://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded[email protected]:~/gitee/vnote_notebooks$ cat ~/.docker/config.json { "auths": {"192.168.31.107": {"auth": "YWRtaW46SGFyYm9yMTIzNDU="} }, "HttpHeaders": {"User-Agent": "Docker-Client/19.03.14 (linux)" }问题-3 防止容器进程没有权限读取生成的配置#


以上关于本文的内容,仅作参考!温馨提示:如遇健康、疾病相关的问题,请您及时就医或请专业人士给予相关指导!

「四川龙网」www.sichuanlong.com小编还为您精选了以下内容,希望对您有所帮助: