# Ansible docker module does not allow me to use bind mode :Z

**URL:** <https://forum.ansible.com/t/ansible-docker-module-does-not-allow-me-to-use-bind-mode-z/20703>\
**Category:** Ansible Project\
**Created:** [February 29, 2016, 11:29am UTC](https://forum.ansible.com/t/ansible-docker-module-does-not-allow-me-to-use-bind-mode-z/20703 "2016-02-29T11:29:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ishan\_jain](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@ishan\_jain](https://forum.ansible.com/u/ishan_jain)\
**Post date:** [February 29, 2016, 11:29am UTC](https://forum.ansible.com/t/ansible-docker-module-does-not-allow-me-to-use-bind-mode-z/20703/1 "2016-02-29T11:29:35Z")

</div>

When i try to run the following task:

- name: start docker container  
docker:  
name: container  
image: img  
state: started  
expose:
- 8301:8182  
volumes:
- /mydata/folder:/opt/mydata/:Z

Ansible poses an error - {“changed”: false, “failed”: true, “msg”: “bind mode needs to either be "ro" or "rw"”}

I was facing a lot of issues with volumes earlier when i was using :ro (manual deployment) which went away after simply using :Z. Now ansible is not letting me use it and the same images are posing errors when starting. Can you please tell me why it is not allowed and how to come around this thing ?

---

<div class="post-metadata">

**Author:** ![Chris\_Houseknecht](https://avatars.discourse-cdn.com/v4/letter/c/c57346/32.png) [@Chris\_Houseknecht](https://forum.ansible.com/u/Chris_Houseknecht)\
**Post date:** [February 29, 2016, 7:05pm UTC](https://forum.ansible.com/t/ansible-docker-module-does-not-allow-me-to-use-bind-mode-z/20703/2 "2016-02-29T19:05:51Z")

</div>

What version of ansible are you running?

According to the doc strings in the docker.py module:

> volumes:
> 
> description:
> 
> - List of volumes to mount within the container
> 
> - 'Use docker CLI-style syntax: C(/host:/container[:mode])’
> 
> - You can specify a read mode for the mount with either C(ro) or C(rw). Starting at version 2.1, SELinux hosts can
> 
> additionally use C(z) or C(Z) mount options to use a shared or private label for the volume.

If I’m understanding the above correctly, options z and Z became available for SE Linux hosts in Ansible 2.1.

Also, I wonder if the format of ` - /mydata/folder:/opt/mydata/:Z` might be incorrect? I would remove the last ‘/’, changing it to ` - /mydata/folder:/opt/mydata:Z`

–Chris

---

<div class="post-metadata">

**Author:** ![ishan\_jain](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@ishan\_jain](https://forum.ansible.com/u/ishan_jain)\
**Post date:** [March 3, 2016, 6:33am UTC](https://forum.ansible.com/t/ansible-docker-module-does-not-allow-me-to-use-bind-mode-z/20703/3 "2016-03-03T06:33:13Z")

</div>

Thanks chris. Can you please share the links to this documentation ?

Also, i was trying to find the Ansible version 2.1. Can you help me here also ?

---

<div class="post-metadata">

**Author:** ![Chris\_Houseknecht](https://avatars.discourse-cdn.com/v4/letter/c/c57346/32.png) [@Chris\_Houseknecht](https://forum.ansible.com/u/Chris_Houseknecht)\
**Post date:** [March 3, 2016, 3:35pm UTC](https://forum.ansible.com/t/ansible-docker-module-does-not-allow-me-to-use-bind-mode-z/20703/4 "2016-03-03T15:35:37Z")

</div>

The doc strings are in the docker.py module code: [https://github.com/ansible/ansible-modules-core/blob/devel/cloud/docker/docker.py](https://github.com/ansible/ansible-modules-core/blob/devel/cloud/docker/docker.py). These doc strings are used to generate the documentation site page for the docker module: [http://docs.ansible.com/ansible/docker\_module.html](http://docs.ansible.com/ansible/docker_module.html).

Ansible 2.1 has not actually been released. 2.1 is what is being worked on in the devel branch today. It is scheduled for [release in April](https://github.com/ansible/ansible/blob/devel/ROADMAP.md). You can run the latest code by installing from source. See some help on how to do that here: [http://docs.ansible.com/ansible/intro\_installation.html#running-from-source](http://docs.ansible.com/ansible/intro_installation.html#running-from-source)

–Chris
