<事象> 環境は、Mac M1
test@test-mac test0410 % docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 0.1.5 f3b2048369e5 2 days ago 69.2MB
test@test-mac test0410 %
この様な状態で、ubuntu:0.1.5を、Docker Hubにアップしようとした。
すると、変なエラー("denied: requested access to the resource is denied")が発生すると言う事象。
test@test-mac test0410 % docker push ubuntu:0.1.5
The push refers to repository [docker.io/bullyng/ubuntu]
An image does not exist locally with the tag: bullyng/ubuntu
test@test-mac test0410 % docker push bullyng/ubuntu
Using default tag: latest
The push refers to repository [docker.io/bullyng/ubuntu]
An image does not exist locally with the tag: bullyng/ubuntu
test@test-mac test0410 % docker push ubuntu:0.1.5
The push refers to repository [docker.io/library/ubuntu]
b9978542eff2: Preparing
eb26b0ccdff8: Preparing
c4db76e353d3: Preparing
a90b58e3523c: Preparing
874b048c963a: Preparing
denied: requested access to the resource is denied
<解決策>
まあ、ここに書いてある通り。
https://qiita.com/shundayo/items/4ae35930fe9f85f535b0
要は、docker hubのユーザー名とImage名を一致させないとダメ。
DockerのNameを調べる。
yonishik_jp@yonishik_jp-mac test0410 % docker ps -a
a9e8a3e3e6bc docker_demo_flask:latest "python app.py" 2 days ago Exited (0) 2 days ago thirsty_darwin
14de7bc61852 ubuntu:0.1.5 "/bin/bash" 2 days ago Exited (127) 2 days ago relaxed_thompson
Docker Hubのユーザー名は、"dockerusrXXX"とする。
ユーザー名/ubuntu で、一旦、保存。
docker commit relaxed_thompson dockerusrXXX/ubuntu
新しいイメージが作成されているのを確認。
test@test-mac test0410 % docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
dockerusrXXX/ubuntu latest 50d1ca518bc3 5 seconds ago 69.2MB
docker_demo_flask bk0.1.1 5bf9f3f5f1f4 2 days ago 861MB
因みに、Docker Loginをしないで、PushするとErrorが発生する。
docker push dockerusrXXX/slotmachinex-alpine3
Using default tag: latest
The push refers to repository [docker.io/dockerusrXXX/slotmachinex-alpine3]
5be4b23e2c71: Preparing
cb3b47dbc581: Preparing
70fb497445e7: Preparing
8851d19e9ae5: Preparing
b93c1bd012ab: Preparing
denied: requested access to the resource is denied
その場合は、Docker Loginをしてから、再度Pushすること。
root@test-ubuntu22-amd:/opt/code/nativeimg# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: dockerusrXXX
Password:
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
この状態で、Docker Hubにpushする。
test@test-mac test0410 % docker push dockerusrXXX/ubuntu
Using default tag: latest
The push refers to repository [docker.io/dockerusrXXX/ubuntu]
5d693d5667a2: Pushed
b9978542eff2: Pushed
eb26b0ccdff8: Pushed
c4db76e353d3: Pushed
a90b58e3523c: Pushed
874b048c963a: Mounted from library/ubuntu
latest: digest: sha256:d7e2bd51a6cd41001d367dd77e60a6f5553853a891f76d0557582eb2010416f9 size: 1564