docker@pull镜像提示异常

问题

docker pull 提示unmarshalling content: invalid character ‘<’

dockerd[2209]: time="2025-06-04T17:58:36.622914940+08:00" level=error msg="Handler for POST /v1.45/images/create returned error: unauthorized: authorize header needed to send HEAD to repository: authorize header needed to send HEAD to repository" spanID=b2940814942432ef traceID=d3eba72211abd57b6291ed0855e43e14

$ docker pull harbor.pxb7.com/gz/test/valuation-engine:4164501-150
Error response from daemon: error unmarshalling content: invalid character '<' looking for beginning of value

错误分析
错误类型: 身份验证失败
具体问题: Docker守护进程无法向镜像仓库发送HEAD请求,因为缺少必要的授权头信息

可能的原因

  • 未登录到镜像仓库
  • 尝试拉取私有镜像但未提供凭据
  • Docker Hub或其他仓库的登录会话已过期

解决

1.登出所有仓库

docker logout

2.重新登录

docker login -u <username> -p <password>

3.检查登录认证信息

# 1. Find the auth string for your harbor registry (this is a conceptual example)
AUTH_STRING=$(jq -r '.auths."harbor.xxx.com".auth' ~/.docker/config.json)

# 2. Decode it (if it's base64 basic auth)
DECODED_AUTH=$(echo "$AUTH_STRING" | base64 -d)

# DECODED_AUTH will be in the format "username:password"
# You can then use this with curl's -u option:
curl -k -u "$DECODED_AUTH" https://harbor.xxx.com/v2/

经过解密发现账户没有项目权限,调整用户后问题得到解决

2c032950fab23e78a3e7c21495b05683.png