{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/164","repository_url":"https://api.github.com/repos/ansible/ansible-modules-core","labels_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/164/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/164/comments","events_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/164/events","html_url":"https://github.com/ansible/ansible-modules-core/issues/164","id":45324815,"number":164,"title":"docker should not create volumes when binding to host machine","user":{"login":"kevin1024","id":21099,"avatar_url":"https://avatars.githubusercontent.com/u/21099?v=3","gravatar_id":"","url":"https://api.github.com/users/kevin1024","html_url":"https://github.com/kevin1024","followers_url":"https://api.github.com/users/kevin1024/followers","following_url":"https://api.github.com/users/kevin1024/following{/other_user}","gists_url":"https://api.github.com/users/kevin1024/gists{/gist_id}","starred_url":"https://api.github.com/users/kevin1024/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevin1024/subscriptions","organizations_url":"https://api.github.com/users/kevin1024/orgs","repos_url":"https://api.github.com/users/kevin1024/repos","events_url":"https://api.github.com/users/kevin1024/events{/privacy}","received_events_url":"https://api.github.com/users/kevin1024/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/bug_report","name":"bug_report","color":"fbca04"},{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/cloud","name":"cloud","color":"c7def8"},{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/P3","name":"P3","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2014-10-09T03:57:46Z","updated_at":"2016-08-01T03:56:14Z","closed_at":null,"body":"This one took awhile to figure out :)\r\n\r\nWhen using this example ansible task:\r\n\r\n```\r\n- name: start nginx\r\n  docker:\r\n    image=nginx\r\n    ports=80:80\r\n    volumes=/root/nginx.conf:/etc/nginx/nginx.conf:ro\r\n    name=nginx\r\n```\r\n\r\nwith [the official docker nginx image](https://registry.hub.docker.com/_/nginx/), and any nginx.conf file in /root/nginx.conf on the host machine, the nginx inside the container won't be able to read the nginx file from the host.\r\n\r\nWhen I run `docker inspect`, I get the following:\r\n\r\n```\r\n...\r\n     \"Volumes\": {\r\n            \"/etc/nginx\": {},\r\n            \"/etc/nginx/nginx.conf\": {},\r\n            \"/usr/share/nginx/html\": {}\r\n        },\r\n...        \"Binds\": [\r\n            \"/root/nginx.conf:/etc/nginx/nginx.conf:ro\"\r\n        ],\r\n...\r\n    \"Volumes\": {\r\n        \"/etc/nginx\": \"/var/lib/docker/vfs/dir/a54606eea3e74c2f869cff5e4f45b4991b171b8a88379720d9c1f090ff89452c\",\r\n        \"/etc/nginx/nginx.conf\": \"/root/nginx.conf\",\r\n        \"/usr/share/nginx/html\": \"/var/lib/docker/vfs/dir/64adbe70ef48b65c9f53a6ae986e44b57acd4fb0f253c62765d755b49394fe02\"\r\n    },\r\n\r\n```\r\n\r\nBUT when I run docker manually with this command:\r\n\r\n`docker run -d -p 80:80 --v /root/nginx.conf:/etc/nginx/nginx.conf:ro nginx\r\n`\r\n\r\neverything works fine!  I get the following output from `docker inspect`:\r\n\r\n```\r\n...\r\n        \"Volumes\": {\r\n            \"/etc/nginx\": {},\r\n            \"/usr/share/nginx/html\": {}\r\n        },\r\n...\r\n        \"Binds\": [\r\n            \"/root/nginx.conf:/etc/nginx/nginx.conf:ro\"\r\n        ],\r\n...\r\n    \"Volumes\": {\r\n        \"/etc/nginx\": \"/var/lib/docker/vfs/dir/880c2b6ec6a0f080c33e8bcb2b56b741e64d0e65c4b7424b68d06cea609a6d12\",\r\n        \"/etc/nginx/nginx.conf\": \"/root/nginx.conf\",\r\n        \"/usr/share/nginx/html\": \"/var/lib/docker/vfs/dir/647ee5dd45807645c041e4b6ab05239b634225547ae7804c4997145c1f8c61a0\"\r\n    },\r\n\r\n```\r\n\r\nThe only difference seems to be that when ansible runs the container, it adds an extra volume *in addition to* adding the bind.  When I run the docker command manually, it works fine, and *does not add the extra volume*.\r\n\r\nThe volume is not necessary in order for the bind mount to work, and actually causes the bind mount to fail.\r\n\r\nOn [line 389](https://github.com/ansible/ansible-modules-core/blob/devel/cloud/docker.py#L389) and [line 396](https://github.com/ansible/ansible-modules-core/blob/devel/cloud/docker.py#L396) of the core docker module, volumes are created even though they aren't needed for bind mounts.\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/comments/236484234","html_url":"https://github.com/ansible/ansible-modules-core/issues/164#issuecomment-236484234","issue_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/164","id":236484234,"user":{"login":"ansibot","id":6585283,"avatar_url":"https://avatars.githubusercontent.com/u/6585283?v=3","gravatar_id":"","url":"https://api.github.com/users/ansibot","html_url":"https://github.com/ansibot","followers_url":"https://api.github.com/users/ansibot/followers","following_url":"https://api.github.com/users/ansibot/following{/other_user}","gists_url":"https://api.github.com/users/ansibot/gists{/gist_id}","starred_url":"https://api.github.com/users/ansibot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansibot/subscriptions","organizations_url":"https://api.github.com/users/ansibot/orgs","repos_url":"https://api.github.com/users/ansibot/repos","events_url":"https://api.github.com/users/ansibot/events{/privacy}","received_events_url":"https://api.github.com/users/ansibot/received_events","type":"User","site_admin":false},"created_at":"2016-08-01T03:56:14Z","updated_at":"2016-08-01T03:56:14Z","body":"@cove, @softzilla, @zfil, @ThomasSteinbach, ping. This issue is waiting on your response.\n[click here for bot help](https://github.com/jctanner/ansibullbot/blob/ISSUE_TRIAGE_CLASS/ISSUE_HELP.md)\n<!--- boilerplate: issue_notify_maintainer --->"}}
{"actor":{"display_login":"ansibot"}}