<p dir="auto">From <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/jansauer/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/jansauer">@jansauer</a> on 2016-11-21T09:40:13Z</p>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<ul dir="auto">
<li>docker_container</li>
</ul>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.2.0.0
  config file =
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.2.0.0
  config file =
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<ul dir="auto">
<li>macOS 10.12.1</li>
<li>ansible, docker and python installed with brew</li>
</ul>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">I try to setup a docker container with ansible <code class="notranslate">docker_container</code> via a docker tls connection.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">hosts:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[local]
localhost ansible_connection=local"><pre class="notranslate"><code class="notranslate">[local]
localhost ansible_connection=local
</code></pre></div>
<p dir="auto">provision.yml</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="---
- hosts: all
  tasks:

  - name: Create a data container
    docker_container:
      name: test
      image: abiosoft/caddy:0.9.3
      tls_hostname: tcp://[xxxx:xxxx:xxxx:xxxx::xxxx]:2376
      tls_verify: true
      key_path: /Users/jan/.docker/custom/server/key.pem
      cert_path: /Users/jan/.docker/custom/server/cert.pem
      cacert_path: /Users/jan/.docker/custom/server/ca.pem
"><pre class="notranslate"><code class="notranslate">---
- hosts: all
  tasks:

  - name: Create a data container
    docker_container:
      name: test
      image: abiosoft/caddy:0.9.3
      tls_hostname: tcp://[xxxx:xxxx:xxxx:xxxx::xxxx]:2376
      tls_verify: true
      key_path: /Users/jan/.docker/custom/server/key.pem
      cert_path: /Users/jan/.docker/custom/server/cert.pem
      cacert_path: /Users/jan/.docker/custom/server/ca.pem

</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible-playbook -i hosts provision.yml"><pre class="notranslate"><code class="notranslate">ansible-playbook -i hosts provision.yml
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">Ansible create a new container</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [Create a data container] *************************************************
fatal: [localhost]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;failed&quot;: true, &quot;msg&quot;: &quot;Failed to import docker-py - No module named requests.exceptions. Try `pip install docker-py`&quot;}
	to retry, use: --limit @/Users/jan/Workspace/ansible/provision.retry

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1"><pre class="notranslate"><code class="notranslate">PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
ok: [localhost]

TASK [Create a data container] *************************************************
fatal: [localhost]: FAILED! =&gt; {"changed": false, "failed": true, "msg": "Failed to import docker-py - No module named requests.exceptions. Try `pip install docker-py`"}
	to retry, use: --limit @/Users/jan/Workspace/ansible/provision.retry

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1
</code></pre></div>
<p dir="auto">I found a workaround for this in another issue...</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="export PYTHONPATH=/usr/local/lib/python2.7/site-packages/:$PYTHONPATH"><pre class="notranslate"><code class="notranslate">export PYTHONPATH=/usr/local/lib/python2.7/site-packages/:$PYTHONPATH
</code></pre></div>
<p dir="auto">After that I get a new error</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="No config file found; using defaults
Loading callback plugin default of type stdout, v2.0 from /usr/local/Cellar/ansible/2.2.0.0_1/libexec/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: provision.yml ********************************************************
1 plays in provision.yml

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
Using module file /usr/local/Cellar/ansible/2.2.0.0_1/libexec/lib/python2.7/site-packages/ansible/modules/core/system/setup.py
&lt;localhost&gt; ESTABLISH LOCAL CONNECTION FOR USER: jan
&lt;localhost&gt; EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p &quot;` echo $HOME/.ansible/tmp/ansible-tmp-1479720959.87-168391919144561 `&quot; &amp;&amp; echo ansible-tmp-1479720959.87-168391919144561=&quot;` echo $HOME/.ansible/tmp/ansible-tmp-1479720959.87-168391919144561 `&quot; ) &amp;&amp; sleep 0'
&lt;localhost&gt; PUT /var/folders/nl/3d67s_ws47n3rhp7y2rq79x80000gn/T/tmpNQ_1vm TO /Users/jan/.ansible/tmp/ansible-tmp-1479720959.87-168391919144561/setup.py
&lt;localhost&gt; EXEC /bin/sh -c 'chmod u+x /Users/jan/.ansible/tmp/ansible-tmp-1479720959.87-168391919144561/ /Users/jan/.ansible/tmp/ansible-tmp-1479720959.87-168391919144561/setup.py &amp;&amp; sleep 0'
&lt;localhost&gt; EXEC /bin/sh -c '/usr/bin/python /Users/jan/.ansible/tmp/ansible-tmp-1479720959.87-168391919144561/setup.py; rm -rf &quot;/Users/jan/.ansible/tmp/ansible-tmp-1479720959.87-168391919144561/&quot; &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'
ok: [localhost]

TASK [Create a data container] *************************************************
task path: /Users/jan/Workspace/ansible/provision.yml:5
Using module file /usr/local/Cellar/ansible/2.2.0.0_1/libexec/lib/python2.7/site-packages/ansible/modules/core/cloud/docker/docker_container.py
&lt;localhost&gt; ESTABLISH LOCAL CONNECTION FOR USER: jan
&lt;localhost&gt; EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p &quot;` echo $HOME/.ansible/tmp/ansible-tmp-1479720960.93-117306363195073 `&quot; &amp;&amp; echo ansible-tmp-1479720960.93-117306363195073=&quot;` echo $HOME/.ansible/tmp/ansible-tmp-1479720960.93-117306363195073 `&quot; ) &amp;&amp; sleep 0'
&lt;localhost&gt; PUT /var/folders/nl/3d67s_ws47n3rhp7y2rq79x80000gn/T/tmpdqVtwD TO /Users/jan/.ansible/tmp/ansible-tmp-1479720960.93-117306363195073/docker_container.py
&lt;localhost&gt; EXEC /bin/sh -c 'chmod u+x /Users/jan/.ansible/tmp/ansible-tmp-1479720960.93-117306363195073/ /Users/jan/.ansible/tmp/ansible-tmp-1479720960.93-117306363195073/docker_container.py &amp;&amp; sleep 0'
&lt;localhost&gt; EXEC /bin/sh -c '/usr/bin/python /Users/jan/.ansible/tmp/ansible-tmp-1479720960.93-117306363195073/docker_container.py; rm -rf &quot;/Users/jan/.ansible/tmp/ansible-tmp-1479720960.93-117306363195073/&quot; &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'
fatal: [localhost]: FAILED! =&gt; {
    &quot;changed&quot;: false,
    &quot;failed&quot;: true,
    &quot;invocation&quot;: {
        &quot;module_args&quot;: {
            &quot;api_version&quot;: null,
            &quot;blkio_weight&quot;: null,
            &quot;cacert_path&quot;: &quot;/Users/jan/.docker/custom/server/ca.pem&quot;,
            &quot;capabilities&quot;: null,
            &quot;cert_path&quot;: &quot;/Users/jan/.docker/custom/server/cert.pem&quot;,
            &quot;cleanup&quot;: false,
            &quot;command&quot;: null,
            &quot;cpu_period&quot;: null,
            &quot;cpu_quota&quot;: null,
            &quot;cpu_shares&quot;: null,
            &quot;cpuset_cpus&quot;: null,
            &quot;cpuset_mems&quot;: null,
            &quot;debug&quot;: false,
            &quot;detach&quot;: true,
            &quot;devices&quot;: null,
            &quot;dns_opts&quot;: null,
            &quot;dns_search_domains&quot;: null,
            &quot;dns_servers&quot;: null,
            &quot;docker_host&quot;: null,
            &quot;entrypoint&quot;: null,
            &quot;env&quot;: null,
            &quot;env_file&quot;: null,
            &quot;etc_hosts&quot;: null,
            &quot;exposed_ports&quot;: null,
            &quot;filter_logger&quot;: false,
            &quot;force_kill&quot;: false,
            &quot;groups&quot;: null,
            &quot;hostname&quot;: null,
            &quot;ignore_image&quot;: false,
            &quot;image&quot;: &quot;abiosoft/caddy:0.9.3&quot;,
            &quot;interactive&quot;: false,
            &quot;ipc_mode&quot;: null,
            &quot;keep_volumes&quot;: true,
            &quot;kernel_memory&quot;: null,
            &quot;key_path&quot;: &quot;/Users/jan/.docker/custom/server/key.pem&quot;,
            &quot;kill_signal&quot;: null,
            &quot;labels&quot;: null,
            &quot;links&quot;: null,
            &quot;log_driver&quot;: null,
            &quot;log_options&quot;: null,
            &quot;mac_address&quot;: null,
            &quot;memory&quot;: &quot;0&quot;,
            &quot;memory_reservation&quot;: null,
            &quot;memory_swap&quot;: null,
            &quot;memory_swappiness&quot;: null,
            &quot;name&quot;: &quot;test&quot;,
            &quot;network_mode&quot;: null,
            &quot;networks&quot;: null,
            &quot;oom_killer&quot;: null,
            &quot;oom_score_adj&quot;: null,
            &quot;paused&quot;: false,
            &quot;pid_mode&quot;: null,
            &quot;privileged&quot;: false,
            &quot;published_ports&quot;: null,
            &quot;pull&quot;: false,
            &quot;purge_networks&quot;: false,
            &quot;read_only&quot;: false,
            &quot;recreate&quot;: false,
            &quot;restart&quot;: false,
            &quot;restart_policy&quot;: null,
            &quot;restart_retries&quot;: null,
            &quot;security_opts&quot;: null,
            &quot;shm_size&quot;: null,
            &quot;ssl_version&quot;: null,
            &quot;state&quot;: &quot;started&quot;,
            &quot;stop_signal&quot;: null,
            &quot;stop_timeout&quot;: null,
            &quot;timeout&quot;: null,
            &quot;tls&quot;: null,
            &quot;tls_hostname&quot;: &quot;tcp://[xxxx:xxxx:xxxx:xxxx::xxxx]:2376&quot;,
            &quot;tls_verify&quot;: true,
            &quot;trust_image_content&quot;: false,
            &quot;tty&quot;: false,
            &quot;ulimits&quot;: null,
            &quot;user&quot;: null,
            &quot;uts&quot;: null,
            &quot;volume_driver&quot;: null,
            &quot;volumes&quot;: null,
            &quot;volumes_from&quot;: null
        },
        &quot;module_name&quot;: &quot;docker_container&quot;
    },
    &quot;msg&quot;: &quot;Error connecting: Error while fetching server API version: ('Connection aborted.', error(2, 'No such file or directory'))&quot;
}
	to retry, use: --limit @/Users/jan/Workspace/ansible/provision.retry

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1
`
``

Copied from original issue: ansible/ansible-modules-core#5685"><pre class="notranslate"><code class="notranslate">No config file found; using defaults
Loading callback plugin default of type stdout, v2.0 from /usr/local/Cellar/ansible/2.2.0.0_1/libexec/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: provision.yml ********************************************************
1 plays in provision.yml

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
Using module file /usr/local/Cellar/ansible/2.2.0.0_1/libexec/lib/python2.7/site-packages/ansible/modules/core/system/setup.py
&lt;localhost&gt; ESTABLISH LOCAL CONNECTION FOR USER: jan
&lt;localhost&gt; EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1479720959.87-168391919144561 `" &amp;&amp; echo ansible-tmp-1479720959.87-168391919144561="` echo $HOME/.ansible/tmp/ansible-tmp-1479720959.87-168391919144561 `" ) &amp;&amp; sleep 0'
&lt;localhost&gt; PUT /var/folders/nl/3d67s_ws47n3rhp7y2rq79x80000gn/T/tmpNQ_1vm TO /Users/jan/.ansible/tmp/ansible-tmp-1479720959.87-168391919144561/setup.py
&lt;localhost&gt; EXEC /bin/sh -c 'chmod u+x /Users/jan/.ansible/tmp/ansible-tmp-1479720959.87-168391919144561/ /Users/jan/.ansible/tmp/ansible-tmp-1479720959.87-168391919144561/setup.py &amp;&amp; sleep 0'
&lt;localhost&gt; EXEC /bin/sh -c '/usr/bin/python /Users/jan/.ansible/tmp/ansible-tmp-1479720959.87-168391919144561/setup.py; rm -rf "/Users/jan/.ansible/tmp/ansible-tmp-1479720959.87-168391919144561/" &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'
ok: [localhost]

TASK [Create a data container] *************************************************
task path: /Users/jan/Workspace/ansible/provision.yml:5
Using module file /usr/local/Cellar/ansible/2.2.0.0_1/libexec/lib/python2.7/site-packages/ansible/modules/core/cloud/docker/docker_container.py
&lt;localhost&gt; ESTABLISH LOCAL CONNECTION FOR USER: jan
&lt;localhost&gt; EXEC /bin/sh -c '( umask 77 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1479720960.93-117306363195073 `" &amp;&amp; echo ansible-tmp-1479720960.93-117306363195073="` echo $HOME/.ansible/tmp/ansible-tmp-1479720960.93-117306363195073 `" ) &amp;&amp; sleep 0'
&lt;localhost&gt; PUT /var/folders/nl/3d67s_ws47n3rhp7y2rq79x80000gn/T/tmpdqVtwD TO /Users/jan/.ansible/tmp/ansible-tmp-1479720960.93-117306363195073/docker_container.py
&lt;localhost&gt; EXEC /bin/sh -c 'chmod u+x /Users/jan/.ansible/tmp/ansible-tmp-1479720960.93-117306363195073/ /Users/jan/.ansible/tmp/ansible-tmp-1479720960.93-117306363195073/docker_container.py &amp;&amp; sleep 0'
&lt;localhost&gt; EXEC /bin/sh -c '/usr/bin/python /Users/jan/.ansible/tmp/ansible-tmp-1479720960.93-117306363195073/docker_container.py; rm -rf "/Users/jan/.ansible/tmp/ansible-tmp-1479720960.93-117306363195073/" &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'
fatal: [localhost]: FAILED! =&gt; {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_args": {
            "api_version": null,
            "blkio_weight": null,
            "cacert_path": "/Users/jan/.docker/custom/server/ca.pem",
            "capabilities": null,
            "cert_path": "/Users/jan/.docker/custom/server/cert.pem",
            "cleanup": false,
            "command": null,
            "cpu_period": null,
            "cpu_quota": null,
            "cpu_shares": null,
            "cpuset_cpus": null,
            "cpuset_mems": null,
            "debug": false,
            "detach": true,
            "devices": null,
            "dns_opts": null,
            "dns_search_domains": null,
            "dns_servers": null,
            "docker_host": null,
            "entrypoint": null,
            "env": null,
            "env_file": null,
            "etc_hosts": null,
            "exposed_ports": null,
            "filter_logger": false,
            "force_kill": false,
            "groups": null,
            "hostname": null,
            "ignore_image": false,
            "image": "abiosoft/caddy:0.9.3",
            "interactive": false,
            "ipc_mode": null,
            "keep_volumes": true,
            "kernel_memory": null,
            "key_path": "/Users/jan/.docker/custom/server/key.pem",
            "kill_signal": null,
            "labels": null,
            "links": null,
            "log_driver": null,
            "log_options": null,
            "mac_address": null,
            "memory": "0",
            "memory_reservation": null,
            "memory_swap": null,
            "memory_swappiness": null,
            "name": "test",
            "network_mode": null,
            "networks": null,
            "oom_killer": null,
            "oom_score_adj": null,
            "paused": false,
            "pid_mode": null,
            "privileged": false,
            "published_ports": null,
            "pull": false,
            "purge_networks": false,
            "read_only": false,
            "recreate": false,
            "restart": false,
            "restart_policy": null,
            "restart_retries": null,
            "security_opts": null,
            "shm_size": null,
            "ssl_version": null,
            "state": "started",
            "stop_signal": null,
            "stop_timeout": null,
            "timeout": null,
            "tls": null,
            "tls_hostname": "tcp://[xxxx:xxxx:xxxx:xxxx::xxxx]:2376",
            "tls_verify": true,
            "trust_image_content": false,
            "tty": false,
            "ulimits": null,
            "user": null,
            "uts": null,
            "volume_driver": null,
            "volumes": null,
            "volumes_from": null
        },
        "module_name": "docker_container"
    },
    "msg": "Error connecting: Error while fetching server API version: ('Connection aborted.', error(2, 'No such file or directory'))"
}
	to retry, use: --limit @/Users/jan/Workspace/ansible/provision.retry

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1
`
``

Copied from original issue: ansible/ansible-modules-core#5685
</code></pre></div>
<h5 dir="auto">ISSUE TYPE</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto"><strong>docker_container</strong> module</p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.1.0.0
  config file =
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.1.0.0
  config file =
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<p dir="auto">No custom configuration.</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Using Ansible on OS X 10.11.5.</p>
<p dir="auto">Docker version:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="docker --version
Docker version 1.12.0-rc4, build e4a0dbc, experimental"><pre class="notranslate"><code class="notranslate">docker --version
Docker version 1.12.0-rc4, build e4a0dbc, experimental
</code></pre></div>
<p dir="auto">docker-py version:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pip show docker-py

---
Metadata-Version: 2.0
Name: docker-py
Version: 1.8.1
Summary: Python client for Docker.
Home-page: https://github.com/docker/docker-py/
Author: UNKNOWN
Author-email: UNKNOWN
Installer: pip
License: UNKNOWN
Location: /Users/rick/tmp/ansible/module-tests/docker_container/env/lib/python2.7/site-packages
Requires: ipaddress, six, requests, backports.ssl-match-hostname, websocket-client
Classifiers:
  Development Status :: 4 - Beta
  Environment :: Other Environment
  Intended Audience :: Developers
  Operating System :: OS Independent
  Programming Language :: Python
  Programming Language :: Python :: 2.6
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3.3
  Programming Language :: Python :: 3.4
  Topic :: Utilities
  License :: OSI Approved :: Apache Software License"><pre class="notranslate"><code class="notranslate">pip show docker-py

---
Metadata-Version: 2.0
Name: docker-py
Version: 1.8.1
Summary: Python client for Docker.
Home-page: https://github.com/docker/docker-py/
Author: UNKNOWN
Author-email: UNKNOWN
Installer: pip
License: UNKNOWN
Location: /Users/rick/tmp/ansible/module-tests/docker_container/env/lib/python2.7/site-packages
Requires: ipaddress, six, requests, backports.ssl-match-hostname, websocket-client
Classifiers:
  Development Status :: 4 - Beta
  Environment :: Other Environment
  Intended Audience :: Developers
  Operating System :: OS Independent
  Programming Language :: Python
  Programming Language :: Python :: 2.6
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3.3
  Programming Language :: Python :: 3.4
  Topic :: Utilities
  License :: OSI Approved :: Apache Software License
</code></pre></div>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">I want to build a custom container on top of a base OS container. So I am trying to start a base OS container.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">I came across this issue in my normal work environment on my Mac. I reproduced it in a clean environment created with virtualenv.</p>
<p dir="auto">Here is the playbook I reproduced it with.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: start an OS image
  hosts: all
  connection: local

  tasks:

  - name: pull the OS image
    docker_container:
      name: my-test-container
      image: ubuntu:16.04
      state: started"><pre class="notranslate"><code class="notranslate">- name: start an OS image
  hosts: all
  connection: local

  tasks:

  - name: pull the OS image
    docker_container:
      name: my-test-container
      image: ubuntu:16.04
      state: started
</code></pre></div>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">Docker container would be started.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<p dir="auto">Here is the verbose failure output of the playboook run.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fatal: [localhost]: FAILED! =&gt; 
{
  &quot;changed&quot;: false, 
   &quot;failed&quot;: true, 
   &quot;invocation&quot;: {
     &quot;module_args&quot;: {
       &quot;api_version&quot;: null, 
       &quot;blkio_weight&quot;: null, 
       &quot;cacert_path&quot;: null, 
       &quot;capabilities&quot;: null, 
       &quot;cert_path&quot;: null, 
       &quot;command&quot;: null, 
       &quot;cpu_period&quot;: null, 
       &quot;cpu_quota&quot;: null, 
       &quot;cpu_shares&quot;: null, 
       &quot;cpuset_cpus&quot;: null, 
       &quot;cpuset_mems&quot;: null, 
       &quot;debug&quot;: false, 
       &quot;detach&quot;: true, 
       &quot;devices&quot;: null, 
       &quot;dns_opts&quot;: null, 
       &quot;dns_search_domains&quot;: null, 
       &quot;dns_servers&quot;: null, 
       &quot;docker_host&quot;: null, 
       &quot;entrypoint&quot;: null, 
       &quot;env&quot;: null, 
       &quot;etc_hosts&quot;: null, 
       &quot;exposed_ports&quot;: null, 
       &quot;filter_logger&quot;: false, 
       &quot;force_kill&quot;: false, 
       &quot;groups&quot;: null, 
       &quot;hostname&quot;: null, 
       &quot;image&quot;: &quot;ubuntu:16.04&quot;, 
       &quot;interactive&quot;: false, 
       &quot;ipc_mode&quot;: null, 
       &quot;keep_volumes&quot;: true, 
       &quot;kernel_memory&quot;: null, 
       &quot;key_path&quot;: null, 
       &quot;kill_signal&quot;: null, 
       &quot;labels&quot;: null, 
       &quot;links&quot;: null, 
       &quot;log_driver&quot;: &quot;json-file&quot;, 
       &quot;log_options&quot;: null, 
       &quot;mac_address&quot;: null, 
       &quot;memory&quot;: &quot;0&quot;, 
       &quot;memory_reservation&quot;: null, 
       &quot;memory_swap&quot;: null, 
       &quot;memory_swappiness&quot;: null, 
       &quot;name&quot;: &quot;my-test-container&quot;, 
       &quot;network_mode&quot;: null, 
       &quot;networks&quot;: null, 
       &quot;oom_killer&quot;: null, 
       &quot;paused&quot;: false, 
       &quot;pid_mode&quot;: null, 
       &quot;privileged&quot;: false, 
       &quot;published_ports&quot;: null, 
       &quot;pull&quot;: false, 
       &quot;read_only&quot;: false, 
       &quot;recreate&quot;: false, 
       &quot;restart&quot;: false, 
       &quot;restart_policy&quot;: null, 
       &quot;restart_retries&quot;: 0, 
       &quot;security_opts&quot;: null, 
       &quot;shm_size&quot;: null, 
       &quot;ssl_version&quot;: null, 
       &quot;state&quot;: &quot;started&quot;, 
       &quot;stop_signal&quot;: null, 
       &quot;stop_timeout&quot;: null, 
       &quot;timeout&quot;: null, 
       &quot;tls&quot;: null, 
       &quot;tls_hostname&quot;: null, 
       &quot;tls_verify&quot;: null, 
       &quot;trust_image_content&quot;: false, 
       &quot;tty&quot;: false, 
       &quot;ulimits&quot;: null, 
       &quot;user&quot;: null, 
       &quot;uts&quot;: null, 
       &quot;volume_driver&quot;: null, 
       &quot;volumes&quot;: null, 
       &quot;volumes_from&quot;: null
    }, 
    &quot;module_name&quot;: &quot;docker_container&quot;
  }, 
  &quot;msg&quot;: &quot;Failed to import docker-py - No module named requests.exceptions. Try `pip install docker-py`&quot;
}"><pre class="notranslate"><code class="notranslate">fatal: [localhost]: FAILED! =&gt; 
{
  "changed": false, 
   "failed": true, 
   "invocation": {
     "module_args": {
       "api_version": null, 
       "blkio_weight": null, 
       "cacert_path": null, 
       "capabilities": null, 
       "cert_path": null, 
       "command": null, 
       "cpu_period": null, 
       "cpu_quota": null, 
       "cpu_shares": null, 
       "cpuset_cpus": null, 
       "cpuset_mems": null, 
       "debug": false, 
       "detach": true, 
       "devices": null, 
       "dns_opts": null, 
       "dns_search_domains": null, 
       "dns_servers": null, 
       "docker_host": null, 
       "entrypoint": null, 
       "env": null, 
       "etc_hosts": null, 
       "exposed_ports": null, 
       "filter_logger": false, 
       "force_kill": false, 
       "groups": null, 
       "hostname": null, 
       "image": "ubuntu:16.04", 
       "interactive": false, 
       "ipc_mode": null, 
       "keep_volumes": true, 
       "kernel_memory": null, 
       "key_path": null, 
       "kill_signal": null, 
       "labels": null, 
       "links": null, 
       "log_driver": "json-file", 
       "log_options": null, 
       "mac_address": null, 
       "memory": "0", 
       "memory_reservation": null, 
       "memory_swap": null, 
       "memory_swappiness": null, 
       "name": "my-test-container", 
       "network_mode": null, 
       "networks": null, 
       "oom_killer": null, 
       "paused": false, 
       "pid_mode": null, 
       "privileged": false, 
       "published_ports": null, 
       "pull": false, 
       "read_only": false, 
       "recreate": false, 
       "restart": false, 
       "restart_policy": null, 
       "restart_retries": 0, 
       "security_opts": null, 
       "shm_size": null, 
       "ssl_version": null, 
       "state": "started", 
       "stop_signal": null, 
       "stop_timeout": null, 
       "timeout": null, 
       "tls": null, 
       "tls_hostname": null, 
       "tls_verify": null, 
       "trust_image_content": false, 
       "tty": false, 
       "ulimits": null, 
       "user": null, 
       "uts": null, 
       "volume_driver": null, 
       "volumes": null, 
       "volumes_from": null
    }, 
    "module_name": "docker_container"
  }, 
  "msg": "Failed to import docker-py - No module named requests.exceptions. Try `pip install docker-py`"
}
</code></pre></div>
<p dir="auto">I am able to start the same container using the <strong>shell</strong> modue.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: start an OS image
  hosts: all
  connection: local

  tasks:

  - name: pull the OS image
    shell: |
      docker run --rm ubuntu:16.04"><pre class="notranslate"><code class="notranslate">- name: start an OS image
  hosts: all
  connection: local

  tasks:

  - name: pull the OS image
    shell: |
      docker run --rm ubuntu:16.04
</code></pre></div>
<p dir="auto">Here is the success output from that playbook.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="changed: [localhost] =&gt; 
{
  &quot;changed&quot;: true, 
   &quot;cmd&quot;: &quot;docker run --rm ubuntu:16.04&quot;, 
   &quot;delta&quot;: &quot;0:00:00.625392&quot;, 
   &quot;end&quot;: &quot;2016-07-24 17:34:22.476927&quot;, 
   &quot;invocation&quot;: {
     &quot;module_args&quot;: {
        &quot;_raw_params&quot;: &quot;docker run --rm ubuntu:16.04&quot;,
         &quot;_uses_shell&quot;: true, 
         &quot;chdir&quot;: null, 
         &quot;creates&quot;: null, 
         &quot;executable&quot;: null, 
         &quot;removes&quot;: null, 
         &quot;warn&quot;: true
      },
      &quot;module_name&quot;: &quot;command&quot;
     }, 
   &quot;rc&quot;: 0, 
   &quot;start&quot;: &quot;2016-07-24 17:34:21.851535&quot;, 
   &quot;stderr&quot;: &quot;&quot;, 
   &quot;stdout&quot;: &quot;&quot;, 
   &quot;stdout_lines&quot;: [], 
   &quot;warnings&quot;: []
}"><pre class="notranslate"><code class="notranslate">changed: [localhost] =&gt; 
{
  "changed": true, 
   "cmd": "docker run --rm ubuntu:16.04", 
   "delta": "0:00:00.625392", 
   "end": "2016-07-24 17:34:22.476927", 
   "invocation": {
     "module_args": {
        "_raw_params": "docker run --rm ubuntu:16.04",
         "_uses_shell": true, 
         "chdir": null, 
         "creates": null, 
         "executable": null, 
         "removes": null, 
         "warn": true
      },
      "module_name": "command"
     }, 
   "rc": 0, 
   "start": "2016-07-24 17:34:21.851535", 
   "stderr": "", 
   "stdout": "", 
   "stdout_lines": [], 
   "warnings": []
}
</code></pre></div>