Reputation: 2972
I am trying to automate docker registry creating step using ansible. Here is my ansible-playbook :
---
- hosts: testansible
tasks:
- name: Getting docker registry
become: true
become_method: sudo
become_user: root
shell: docker run -d -p 443:443 --restart=always --name registry -v /home/myuser/certs:/certs -e REGISTRY_HTTP_ADDR=0.0.0.0:443 -e REGISTRY_HTTP_TLS_CERTIFICATE=/home/myuser/certs/domain.crt -e REGISTRY_HTTP_TLS_KEY=/home/myuser/certs/domain.key registry:2
When I run this, it doesnt give errors.
PLAY RECAP
127.0.0.1 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
But in docker logs
level=fatal msg="open /home/myuser/certs/domain.crt: no such file or directory"
But file is there in the exact location.
If I run docker run
step manually, it creates docker registry without an error.
Why am I getting this error?
Here testansible
is configured to use localhost.
Environment : Ubuntu 16.04
Ansible : ansible 2.8.5
Upvotes: 0
Views: 202
Reputation: 2625
You are mounting /home/myuser/certs
to /certs
inside the container. You either need to update REGISTRY_HTTP_TLS_CERTIFICATE
and REGISTRY_HTTP_TLS_KEY
to reflect this, or you need to change your volume mapping to -v /home/myuser/certs:/home/myuser/certs
Upvotes: 1