Hi I’m trying out the docker module and I want to run it without sudo as root, but dont know why I get permission errors, running locally works great.
I’ve added usermod -aG docker stefan
stefan@docker1:~$ groups
stefan docker
stefan@docker1:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
097yj2dfafb02 webtest:latest "apache2ctl -DFOREGR 35 minutes ago Up 35 minutes 18.18.10.16:8080->80/tcp webtest
stefan@docker1:~$ docker stop 4927fdfafb02
097yj2dfafb02
IP
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 18.10.10.16/24 brd 10.18.10.255 scope global eth0
And the ansible command:
- name: remove container
docker:
name: “{{ ansible_hostname }}”
image: webtest
state: absent
sudo: no
failed: [18.18.10.16] => {“changed”: false, “failed”: true}
msg: ConnectionError(ProtocolError(‘Connection aborted.’, error(13, ‘Permission denied’)),)
I dont know why I get permission denied when I can run the commands locally with docker.
as a followup:
stefan@docker1:~$ python
Python 2.7.9 (default, Mar 1 2015, 12:57:24)
[GCC 4.9.2] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
from docker import Client
c = Client(base_url=‘unix://var/run/docker.sock’)
c.containers()
[{u’Status’: u’Up About a minute’, u’Created’: 1432548197, u’Image’: u’webtest:latest’, u’Labels’: {}, u’Ports’: [{u’IP’: u’18.18.10.16’, u’Type’: u’tcp’, u’PublicPort’: 8080, u’PrivatePort’: 80}], u’Command’: u’apache2ctl -DFOREGROUND’, u’Names’: [u’/webtest’], u’Id’: u’097yj2dfafb0215e10e8ef7fb506866e72782ea211678e2ba8700215b033011’}]
this works aswell, so the python-py have permission when ran locally. and I initate the playbook with
ansible-playbook -i hosts.yml -l webtest test.yml -u stefan
and facts is gathered without issues
Did you find a resolution? I am having the same problem
Is there already a bug report for this? Because I can also reproduce this.
i have the same problem, but i try using shell module with “sudo docker build -f .” , this working but the console output show me warning message, any have solution.
Sorry by my inglish