Unable to push the image dockerhub using ansible playbook

  ansible, docker, docker-registry

Thanks in advance for the help.

[email protected]:~$ sudo pass ls
Password Store
└── docker-credential-helpers
├── aW5kZXguZG9ja2VyLmlv
│   └── sambasival
└── docker-pass-initialized-check

[email protected]:/opt/docker$ cat ~/my_password.txt |sudo docker login index.docker.io –username sambasival –password-stdin
Login Succeeded
[email protected]:/opt/docker$ docker push sambasival/simple-dops-image:latest
The push refers to repository [docker.io/sambasival/simple-dops-image]
695ca772596b: Preparing
7aa976df10c0: Preparing
d4f9607ef3ba: Preparing
b59bec8e9230: Preparing
6ea995e9b7d3: Preparing
c0848348e2f7: Waiting
79c550eb7bd2: Waiting
7095af798ace: Waiting
fe6a4fdbedc0: Waiting
e4d0e810d54a: Waiting
4e006334a6fd: Waiting
denied: requested access to the resource is denied

[email protected]:/opt/docker$ cat create-simple-devops-image.yml

  • hosts: all
    become: true

    tasks:

    • name: create docker image using war file
      command: docker build -t simple-dops-image:latest .
      args:
      chdir: /opt/docker

    • name: create tag to image
      command: docker tag simple-dops-image:latest sambasival/simple-dops-image:latest

    • name: push image on dockerhub
      command: docker image push sambasival/simple-dops-image:latest

    • name: remove docker images from ansible server
      command: docker rmi simple-devops-image:latest sambasival/simple-devops-image
      ignore_errors: yes

TASK [push image on dockerhub] *******************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["docker", "image", "push", "sambasival/simple-dops-image:latest"], "delta": "0:00:04.361993", "end": "2021-07-22 00:24:28.132594", "msg": "non-zero return code", "rc": 1, "start": "2021-07-22 00:24:23.770601", "stderr": "denied: requested access to the resource is denied", "stderr_lines": ["denied: requested access to the resource is denied"], "stdout": "The push refers to repository [docker.io/sambasival/simple-dops-image]n695ca772596b: Preparingn7aa976df10c0: Preparingnd4f9607ef3ba: Preparingnb59bec8e9230: Preparingn6ea995e9b7d3: Preparingnc0848348e2f7: Preparingn79c550eb7bd2: Preparingn7095af798ace: Preparingnfe6a4fdbedc0: Preparingne4d0e810d54a: Preparingn4e006334a6fd: Preparingnc0848348e2f7: Waitingn79c550eb7bd2: Waitingn7095af798ace: Waitingnfe6a4fdbedc0: Waitingne4d0e810d54a: Waitingn4e006334a6fd: Waiting", "stdout_lines": ["The push refers to repository [docker.io/sambasival/simple-dops-image]", "695ca772596b: Preparing", "7aa976df10c0: Preparing", "d4f9607ef3ba: Preparing", "b59bec8e9230: Preparing", "6ea995e9b7d3: Preparing", "c0848348e2f7: Preparing", "79c550eb7bd2: Preparing", "7095af798ace: Preparing", "fe6a4fdbedc0: Preparing", "e4d0e810d54a: Preparing", "4e006334a6fd: Preparing", "c0848348e2f7: Waiting", "79c550eb7bd2: Waiting", "7095af798ace: Waiting", "fe6a4fdbedc0: Waiting", "e4d0e810d54a: Waiting", "4e006334a6fd: Waiting"]}
to retry, use: –limit @/opt/docker/create-simple-devops-image.retry

Source: Docker Questions

LEAVE A COMMENT