You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker登录报unauthorized错误:service1账号终端登录失败但GUI正常

Docker仓库终端登录失败(GUI登录正常)的排查方案

service1账号状态正常,可正常登录镜像仓库GUI门户,但执行Docker终端登录命令时返回认证失败,相同命令用user1账号可成功登录。具体命令及报错如下:

PS docker login -u service1 -p password localregitry.ru
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: Get "https://localregitry.ru/v2/": unauthorized: authentication required

PS docker login -u user1 -p password localregitry.ru
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Login Succeeded

排查步骤

  • 核对账号权限配置:确认service1账号是否拥有Docker仓库的终端访问权限。部分仓库的GUI登录权限与CLI/API访问权限是独立配置的,可能GUI仅需基础登录权限,但CLI调用v2接口需要额外的仓库操作权限。
  • 验证认证凭证类型:部分服务类账号(如service1)可能要求使用API密钥而非普通密码登录。尝试替换凭证重新执行登录:
    docker login -u service1 -p <service1-api-key> localregitry.ru
    
  • 检查账号访问限制:对比service1和user1的账号属性,确认是否存在IP白名单、用户组策略等终端访问限制,导致service1无法通过CLI认证。
  • 清除本地Docker认证缓存:本地可能留存旧的无效认证信息,清除后重新尝试:
    # Windows系统清除缓存
    Remove-Item "$env:USERPROFILE\.docker\config.json"
    docker login -u service1 -p password localregitry.ru
    
  • 手动验证API访问:直接调用仓库v2接口验证service1的认证有效性,定位是否为API层面的权限问题:
    Invoke-WebRequest -Uri "https://localregitry.ru/v2/" -Headers @{"Authorization"="Basic "+[Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("service1:password"))}
    

内容的提问来源于stack exchange,提问作者Alexander Kozachenko

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 01:30:57