Q:

denied: requested access to the resource is denied where using docker command to push image

I am using this command to push image to aliyun docker hub:
#!/usr/bin/env bash

set -u

set -e

set -x

./gradlew clean :soa-report-analysis:soa-report-analysis-service:build -x test

docker build -f ./Dockerfile -t="dabai-fat/soa-report-analysis-service:v1.0.0" .

/usr/bin/expect <<-EOF
set timeout 30
spawn docker login --username=example registry.cn-shanghai.aliyuncs.com
expect "Password:"
send "password\r"
expect eof
EOF

docker tag dabai-fat/soa-report-analysis-service:v1.0.0 registry.cn-hangzhou.aliyuncs.com/dabai_app_k8s/dabai_fat/soa-report-analysis:v1.0.0
docker push registry.cn-hangzhou.aliyuncs.com/dabai_app_k8s/dabai_fat/soa-report-analysis:v1.0.0

the log output:
Successfully tagged dabai-fat/soa-report-analysis-service:v1.0.0
+ /usr/bin/expect
spawn docker login --username=example registry.cn-shanghai.aliyuncs.com
Password:
WARNING! Your password will be stored unencrypted in /Users/dabaidabai/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
+ docker tag dabai-fat/soa-report-analysis-service:v1.0.0 registry.cn-hangzhou.aliyuncs.com/dabai_app_k8s/dabai_fat/soa-report-analysis:v1.0.0
+ docker push registry.cn-hangzhou.aliyuncs.com/dabai_app_k8s/dabai_fat/soa-report-analysis:v1.0.0
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/dabai_app_k8s/dabai_fat/soa-report-analysis]
75ddf8b46bd1: Preparing
6ed9cedc9f80: Preparing
edd61588d126: Preparing
9b9b7f3d56a0: Preparing
f1b5933fe4b5: Preparing
denied: requested access to the resource is denied

using the same command,I tried in 4 machine, only one machine could push success , is it bind with machine mac address? what should I do to make it work in any machine?This is the .docker/config.json
{
        "auths": {
                "registry.cn-shanghai.aliyuncs.com": {
                        "auth": "password"
                }
        },
        "HttpHeaders": {
                "User-Agent": "Docker-Client/19.03.5 (darwin)"
        },
        "stackOrchestrator": "kubernetes"
}

A:

I am copied the config.json from other machine,the file's user was root.so change the file to current user could fix this problem.
chown -R dabaidabai ~/.docker/config.json

hope this may help you.If you do not make sure the problem, try to execute this command:
docker pull registry.cn-hangzhou.aliyuncs.com/dabai_app_k8s/dabai_fat/soa-report-analysis:v1.0.0

It may give tips docker read config file permission denied.

