
# 推送镜像到SWR失败
使用步骤"制作镜像并推送到SWR"或"执行Docker命令"时，因参数错误、环境问题等，可能会出现推送镜像失败，可参考各场景对应解决方案处理。
- [推送镜像提示无权限]（denied: you do not have the permission）
- [推送镜像提示组织数达到上限]（denied: The number of namespaces exceeds the upper limit）
- [推送镜像提示未登录]（denied: You may not login yet）
- [推送镜像提示认证失败]（denied: Authenticate Error）
- [推送镜像提示组织名非法]（invalid reference format）
- [推送镜像提示本地镜像不存在]（An image does not exist locally with the tag: \*\*\*）
- [推送镜像提示非法摘要]（digest invalid: Invalid digest）
 #### 推送镜像提示无权限
**错误日志**
上传镜像到SWR仓库，提示如下错误：
```
denied: you do not have the permission 
  
 [ERROR]  : [pluginFrame] step run failed, errorMessage: DEV.CB.0210044, Docker push failed
```
**分析处理**
此错误表示当前用户对目标组织没有权限，请逐步排查以下可能的原因：
1. 编辑构建任务，单击"制作镜像并推送到SWR仓库"构建步骤，查看组织名。
2. 登录容器镜像服务，在组织管理里查看组织是否存在。
   - 组织不存在，[创建组织](https://support.huaweicloud.com/usermanual-swr/swr_01_0014.html)即可（组织数不可超过上限）。
   
   
   
   - 组织存在，但当前用户对该组织没有编辑权限，推送镜像时仍然会出现此错误，管理员可参考[授权管理](https://support.huaweicloud.com/usermanual-swr/swr_01_0015.html)选择性为当前用户授权。
    
 
 #### 推送镜像提示组织数达到上限
**错误日志**
```
denied: The number of namespaces exceeds the upper limit 
  
 [ERROR] : [pluginFrame] step run failed, errorMessage: DEV.CB.0210044, Docker push failed
```
**分析处理**
推送镜像时，如果使用未被任何用户占用的全新组织名，SWR服务会尝试为当前租户创建该组织；由于SWR服务限制了每个租户可创建的组织数，如果超过此限制，则会出现该错误。
出现此错误时，使用管理员账号（或任何有SWR组织管理权限的账号）前往[组织管理](https://console.huaweicloud.com/swr/?locale=zh-cn#/app/organization/list)并切换至对应region，查看已有的组织列表，选择使用已有组织或删除无用组织即可。
 #### 推送镜像提示未登录
**错误日志**
```
denied: You may not login yet 
 [ERROR] : [pluginFrame] step run failed, errorMessage: fail to execute docker command
```
**分析处理**
此类错误发生的原因一般有如下两种：
- push操作前未使用"docker login"命令登录，此时添加对应登录命令即可。
- 执行了登录命令，但是登录命令中SWR地址错误，导致执行没报错但实际登录未生效，需要核对登录命令是否正确。
 
 #### 推送镜像提示认证失败
**错误日志**
```
Error response from daemon: Get https://swr.example.example.com/v2/: denied: Authenticate Error 
 [ERROR] : [pluginFrame] step run failed, errorMessage: fail to execute docker command.
```
**分析处理**
此类错误一般为SWR登录命令中账号/密码填写错误或临时登录账号信息已过期导致，[获取有效登录指令](https://support.huaweicloud.com/usermanual-swr/swr_01_1000.html)重试即可。
 #### 推送镜像提示组织名非法
**错误日志**
```
invalid reference format 
 [ERROR] : [pluginFrame] step run failed, errorMessage: fail to execute docker command.
```
**分析处理**
SWR服务对"组织"命名有相应格式要求，推送镜像时，如果使用的组织名不满足其格式要求，则会出现此错误。
出现此错误时，请前往[组织管理](https://console.huaweicloud.com/swr/?locale=zh-cn#/app/organization/list)并切换至对应region，核对填写的组织名是否正确；如果属于新建组织，请尝试按规范手动创建组织后再试。
 #### 推送镜像提示本地镜像不存在
**错误日志**
```
[2022-03-05 17:01:05.816] An image does not exist locally with the tag: 
swr.example.example.com/demo/faqdemo1 
 [ERROR] : [pluginFrame] step run failed, errorMessage: fail to execute docker command.
```
**分析处理**
此类错误一般为镜像制作失败或push命令中镜像名、标签等信息填写错误，导致push命令中期望的镜像与build/tag命令中实际生成的镜像不一致，需要检查镜像制作过程或push参数是否正确。
此例中镜像docker push swr.example.example.com/demo/faqdemo1:v1.1 中faqdemo1填写错误，build参数中指定的镜像名为faqdemo，修正push参数后再试即可。
 #### 推送镜像提示非法摘要
**错误日志**
```
digest invalid: Invalid digest
```
**分析处理**
此问题一般为SWR网络不稳定导致，重试几次即可。
