harbor登录时报错error parsing HTTP 404 response body: invalid character

发布时间 2023-10-08 14:11:05作者: muzlei

**harbor登录时报如下错误: **

[root@localhost TDFW-publish-tar]# docker login --username=user1 192.168.2.10:8090 --password  user1_pass
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get "http://192.168.2.10:8090/v2/": error parsing HTTP 404 response body: invalid character '<' looking for beginning of value: "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n<title>Error 404 Not Found</title>\n</head>\n<body><h2>HTTP ERROR 404</h2>\n<p>Problem accessing /service/token. Reason:\n<pre>    Not Found</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>\n\n</body>\n</html>\n"

此时查看/etc/docker/daemon.json 是否已经设置

[root@localhost TDFW-publish-tar]#  cat /etc/docker/daemon.json 
{
  "insecure-registries":["192.168.2.10:8090"],
  "registry-mirrors": ["http://hub-mirror.c.163.com"],
  "data-root": "/data/docker-home"
}

从上面可以看到已经设置了,想到之前对harbor的配置信息做了调整(将内网地址映射成了外网地址):

vim /opt/harbor/common/config/core/env
EXT_ENDPOINT=http://1.1.1.1:18003

后面由于关闭了外网映射所以导致了登陆失败,此时只需要将其改为内网地址即可,具体如下:

EXT_ENDPOINT=http://172.16.16.16:10241

进入harbor目录修改

# 容器内端口8080,外部映射端口8090
[root@localhost harbor]# ls
common     docker-compose.yml  harbor.v2.3.4.tar.gz  harbor.yml.tmpl  install.sh                    LICENSE     prepare
common.sh  harbor_data         harbor.yml            https            isunland-pms-nacos-0.0.1.tar  log-harbor

[root@localhost harbor]# vim common/config/core/env 
#EXT_ENDPOINT=http://192.168.2.10:8080
#改成》
EXT_ENDPOINT=http://192.168.2.10:8090

此时重启harbor即可
docker-compose down
docker-compose up -d

此时再次登陆问题解决了

[root@localhost TDFW-publish-tar]# docker login --username=user1 192.168.2.10:8090 --password  user1_pass
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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