community.docker
community.docker copied to clipboard
pull fails if build and image in docker-compose file
Summary
I have a docker compose file which has containers from docker hub as well as some that have to be locally build.
version: '3'
services:
caddy:
container_name: caddy
image: caddy
volumes:
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
- ./caddy/data:/data
- ./caddy/config:/config
restart: unless-stopped
ports:
- "80:80"
- "443:443"
networks:
- proxynet
diun:
container_name: diun
image: ghcr.io/crazy-max/diun
command: serve
volumes:
- "./diun/data:/data"
- "./diun/diun.yml:/diun.yml:ro"
- "/var/run/docker.sock:/var/run/docker.sock"
environment:
- "TZ=Europe/Berlin"
- "LOG_LEVEL=info"
- "LOG_JSON=false"
restart: always
bafu:
container_name: bafu
build: ./bafu
image: bafu
command: "python bafu.py"
restart: unless-stopped
networks:
- proxynet
networks:
proxynet:
name: services_network
I use this step in my playbook:
- name: pull and restart all containers
docker_compose:
project_src: '{{ hostvars[inventory_hostname].docker_compose_path }}'
pull: yes
state: present
Which results in this error:
fatal: [host123]: FAILED! => changed=false
errors: []
module_stderr: ''
module_stdout: ''
msg: 'Error: pull failed with 404 Client Error for http+docker://localhost/v1.41/images/create?tag=latest&fromImage=bafu: Not Found ("pull access denied for bafu, repository does not exist or may require ''docker login'': denied: requested access to the resource is denied")'
Unless I remove image: bafu
from the docker-compose file. The image
is set so that the container get its name from it as described in the compose file reference
If I do a docker image ls
I see that there is the image with the name bafu
:
bafu latest bbc569868553 2 months ago 118MB
Issue Type
Bug Report
Component Name
docker_compose
Ansible Version
$ ansible --version
ansible [core 2.12.1]
config file = /home/bouni/ansible/ansible.cfg
configured module search path = ['/home/bouni/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.10/site-packages/ansible
ansible collection location = /home/bouni/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.10.2 (main, Jan 15 2022, 19:56:27) [GCC 11.1.0]
jinja version = 3.0.3
libyaml = True
Community.general Version
$ ansible-galaxy collection list community.general
# /usr/lib/python3.10/site-packages/ansible_collections
Collection Version
----------------- -------
community.general 4.3.0
# /home/bouni/.ansible/collections/ansible_collections
Collection Version
----------------- -------
community.general 4.3.0
Configuration
$ ansible-config dump --only-changed
DEFAULT_STDOUT_CALLBACK(/home/bouni/ansible/ansible.cfg) = yaml
INTERPRETER_PYTHON(/home/bouni/ansible/ansible.cfg) = auto_silent
INVENTORY_ENABLED(/home/bouni/ansible/ansible.cfg) = ['yaml']
OS / Environment
Target OS is Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-96-generic x86_64)
Steps to Reproduce
ansible-playbook -i inventory/hosts.yaml plays/update-all.yaml
Expected Results
pull all containers and restart those which have changed
Actual Results
fatal: [host123]: FAILED! => changed=false
errors: []
module_stderr: ''
module_stdout: ''
msg: 'Error: pull failed with 404 Client Error for http+docker://localhost/v1.41/images/create?tag=latest&fromImage=bafu: Not Found ("pull access denied for bafu, repository does not exist or may require ''docker login'': denied: requested access to the resource is denied")'
Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
Files identified in the description: None
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
This module has been part of community.docker for quite some time now. I thus moved your issue over to the correct collection repo.