Volumes also don't appear to be working for me either. I can start the
container, but the mounted volume is always empty inside the container,
despite the host having two volumes. As the original poster says, if I
just use the docker command directly, the volume mount works as expected.
- name: Start Registry
docker: image={{docker_image}} state=running
volumes="/etc/docker-registry/keys:/etc/docker-registry/keys" name=registry
See anything wrong?
On Tuesday, August 26, 2014 8:27:59 PM UTC-4, James Cammarata wrote:
>
> I merged in support for specifying :ro/:rw a few weeks ago, and it was
> included in the 1.7.1 release.
>
>
> On Tue, Aug 26, 2014 at 2:26 PM, Steven Truong <[email protected]
> <javascript:>> wrote:
>
>> TASK: [echo $myhome]
>> **********************************************************
>> ok: [localhost] => {
>> "myhome": {
>> "changed": true,
>> "cmd": "echo $HOME",
>> "delta": "0:00:00.165168",
>> "end": "2014-08-26 19:22:36.055947",
>> "invocation": {
>> "module_args": "echo $HOME",
>> "module_name": "shell"
>> },
>> "rc": 0,
>> "start": "2014-08-26 19:22:35.890779",
>> "stderr": "",
>> "stdout": "/root",
>> "stdout_lines": [
>> "/root"
>> ]
>> }
>> }
>>
>>
>> I removed :rw and :ro and it still did not work. I think that Ansible
>> does not support these third fields yet.
>>
>> Steven.
>>
>> On Tuesday, August 26, 2014 12:16:30 PM UTC-7, James Cammarata wrote:
>>
>>> If you remove the variables and hard-code the paths, does it work for
>>> you then? I'm curious if things like spaces/newlines in the stdout
>>> variables you're using are causing the problem.
>>>
>>> You might want to put in a "- debug: var=myhome" before the docker task
>>> to view the value of stdout there.
>>>
>>>
>>> On Tue, Aug 26, 2014 at 2:05 PM, Steven Truong <[email protected]>
>>> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I tried to use the volumes option and nothing seems to work for me.
>>>>
>>>> I want to mount 2 directories ~/dockerstorage/model and
>>>> ~/repo/ops/ansible to the container and I used either of these commands
>>>> and
>>>> nothing worked.
>>>>
>>>> docker: image=registry.my.com:5000/steven/centos65_prod_ready:v1
>>>> docker_url=tcp://{{ ansible_default_ipv4.address }}:7777
>>>> publish_all_ports=True state=running volumes=/home/kafka/models:{{
>>>> myhome.stdout }}/dockerstorage/models:rw,/usr/local/src/ansible:{{
>>>> myhome.stdout }}/repo/ops/ansible:ro
>>>>
>>>> docker: image=registry.my.com:5000/steven/centos65_prod_ready:v1
>>>> docker_url=tcp://{{ ansible_default_ipv4.address }}:7777
>>>> publish_all_ports=True state=running volumes={{ myhome.stdout
>>>> }}/dockerstorage/models:/home/kafka/models:rw,{{ myhome.stdout
>>>> }}/repo/ops/ansible:/usr/local/src/ansible:ro
>>>>
>>>> I sshed into the containers and the mounted points in either case were
>>>> all empty.
>>>>
>>>> I ran using docker directly and it worked for me:
>>>>
>>>>
>>>>
>>>> docker run -d -P -v
>>>> /home/steven/dockerstorage/models:/home/kafka/models:rw -v
>>>> /home/steven/repo/ops/ansible:/usr/local/src/ansible:ro
>>>> registry.my.com:5000/steven/centos65_prod_ready:v1
>>>>
>>>>
>>>>
>>>>
>>>> Please let me know what is the right ways to use "volumes" for docker.
>>>> From the comments in the docker module, it appears to me that the
>>>> /mnt:/tmp is in reversed orders from those of the docker command line
>>>> because of the case when we just want to create a volume such as /mnt and
>>>> there is no equivalent mounted point from the host. I think that this is
>>>> confusing and users have to read the codes to find out.
>>>>
>>>> Thanks,
>>>> Steven.
>>>>
>>>> [root@sc2-dock1 cloud]# pwd
>>>> /usr/local/ansible/library/cloud
>>>>
>>>>
>>>> class DockerManager:
>>>>
>>>> counters = {'created':0, 'started':0, 'stopped':0, 'killed':0,
>>>> 'removed':0, 'restarted':0, 'pull':0}
>>>>
>>>> def __init__(self, module):
>>>> self.module = module
>>>>
>>>> self.binds = None
>>>> self.volumes = None
>>>> if self.module.params.get('volumes'):
>>>> self.binds = {}
>>>> self.volumes = {}
>>>> vols = self.module.params.get('volumes')
>>>> for vol in vols:
>>>> parts = vol.split(":")
>>>> # host mount (e.g. /mnt:/tmp, bind mounts host's /tmp
>>>> to /mnt in the container)
>>>> if len(parts) == 2:
>>>> self.volumes[parts[1]] = {}
>>>> self.binds[parts[0]] = parts[1]
>>>> # docker mount (e.g. /www, mounts a docker volume /www
>>>> on the container at the same location)
>>>> else:
>>>> self.volumes[parts[0]] = {}
>>>>
>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Ansible Project" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>>
>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>> msgid/ansible-project/40310529-7426-4321-b9a6-
>>>> 20a9f73d9005%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/ansible-project/40310529-7426-4321-b9a6-20a9f73d9005%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/5f1b7eb9-d3b1-4907-b01f-ae291f16b636%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/5f1b7eb9-d3b1-4907-b01f-ae291f16b636%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/b1f989cf-6b9b-4e6c-972c-861b72fa1da6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.