We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
"devices" support in docker driver
# Issue Type

- Feature request

# Molecule and Ansible details

```
$ ansible --version && molecule --version
ansible 2.8.5
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/sylvain/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/sylvain/venv/molecule/lib/python3.6/site-packages/ansible
  executable location = /home/sylvain/venv/molecule/bin/ansible
  python version = 3.6.8 (default, Aug 20 2019, 17:12:48) [GCC 8.3.0]
molecule, version 2.22
```

Molecule installation method (one of):

- pip

Ansible installation method (one of):

- pip

# Desired Behavior

The docker driver does not support the `devices` option available in the `docker_container` ansible module, so we can't test roles that are using fuse for example, except by using `privileged` option which is quite dangerous. Can you please support for this option?

"devices" support in docker driver
# Issue Type

- Feature request

# Molecule and Ansible details

```
$ ansible --version && molecule --version
ansible 2.8.5
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/sylvain/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/sylvain/venv/molecule/lib/python3.6/site-packages/ansible
  executable location = /home/sylvain/venv/molecule/bin/ansible
  python version = 3.6.8 (default, Aug 20 2019, 17:12:48) [GCC 8.3.0]
molecule, version 2.22
```

Molecule installation method (one of):

- pip

Ansible installation method (one of):

- pip

# Desired Behavior

The docker driver does not support the `devices` option available in the `docker_container` ansible module, so we can't test roles that are using fuse for example, except by using `privileged` option which is quite dangerous. Can you please support for this option?


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `molecule/driver/docker.py`
Content:
```
1 #  Copyright (c) 2015-2018 Cisco Systems, Inc.
2 #
3 #  Permission is hereby granted, free of charge, to any person obtaining a copy
4 #  of this software and associated documentation files (the "Software"), to
5 #  deal in the Software without restriction, including without limitation the
6 #  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 #  sell copies of the Software, and to permit persons to whom the Software is
8 #  furnished to do so, subject to the following conditions:
9 #
10 #  The above copyright notice and this permission notice shall be included in
11 #  all copies or substantial portions of the Software.
12 #
13 #  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 #  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 #  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 #  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 #  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 #  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 #  DEALINGS IN THE SOFTWARE.
20 
21 from __future__ import absolute_import
22 
23 import os
24 
25 from molecule import logger
26 from molecule.api import Driver
27 from molecule.util import lru_cache
28 from molecule.util import sysexit_with_message
29 
30 log = logger.get_logger(__name__)
31 
32 
33 class Docker(Driver):
34     """
35     The class responsible for managing `Docker`_ containers.  `Docker`_ is
36     the default driver used in Molecule.
37 
38     Molecule leverages Ansible's `docker_container`_ module, by mapping
39     variables from ``molecule.yml`` into ``create.yml`` and ``destroy.yml``.
40 
41     .. _`docker_container`: https://docs.ansible.com/ansible/latest/docker_container_module.html
42     .. _`Docker Security Configuration`: https://docs.docker.com/engine/reference/run/#security-configuration
43     .. _`Docker daemon socket options`: https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-socket-option
44 
45     .. code-block:: yaml
46 
47         driver:
48           name: docker
49         platforms:
50           - name: instance
51             hostname: instance
52             image: image_name:tag
53             dockerfile: Dockerfile.j2
54             pull: True|False
55             pre_build_image: True|False
56             registry:
57               url: registry.example.com
58               credentials:
59                 username: $USERNAME
60                 password: $PASSWORD
61                 email: user@example.com
62                 user: root
63             override_command: True|False
64             command: sleep infinity
65             tty: True|False
66             pid_mode: host
67             privileged: True|False
68             security_opts:
69               - seccomp=unconfined
70             volumes:
71               - /sys/fs/cgroup:/sys/fs/cgroup:ro
72             keep_volumes: True|False
73             tmpfs:
74               - /tmp
75               - /run
76             capabilities:
77               - SYS_ADMIN
78             sysctls:
79               net.core.somaxconn: 1024
80               net.ipv4.tcp_syncookies: 0
81             exposed_ports:
82               - 53/udp
83               - 53/tcp
84             published_ports:
85               - 0.0.0.0:8053:53/udp
86               - 0.0.0.0:8053:53/tcp
87             ulimits:
88               - nofile:262144:262144
89             dns_servers:
90               - 8.8.8.8
91             etc_hosts: "{'host1.example.com': '10.3.1.5'}"
92             networks:
93               - name: foo
94               - name: bar
95             network_mode: host
96             purge_networks: true
97             docker_host: tcp://localhost:12376
98             cacert_path: /foo/bar/ca.pem
99             cert_path: /foo/bar/cert.pem
100             key_path: /foo/bar/key.pem
101             tls_verify: true
102             env:
103               FOO: bar
104             restart_policy: on-failure
105             restart_retries: 1
106             buildargs:
107                 http_proxy: http://proxy.example.com:8080/
108 
109     If specifying the `CMD`_ directive in your ``Dockerfile.j2`` or consuming a
110     built image which declares a ``CMD`` directive, then you must set
111     ``override_command: False``. Otherwise, Molecule takes care to honour the
112     value of the ``command`` key or uses the default of ``bash -c "while true;
113     do sleep 10000; done"`` to run the container until it is provisioned.
114 
115     When attempting to utilize a container image with `systemd`_ as your init
116     system inside the container to simulate a real machine, make sure to set
117     the ``privileged``, ``volumes``, ``command``, and ``environment``
118     values. An example using the ``centos:7`` image is below:
119 
120     .. note:: Do note that running containers in privileged mode is considerably
121               less secure. For details, please reference `Docker Security
122               Configuration`_
123 
124     .. note:: With the environment variable ``DOCKER_HOST`` the user can bind
125               Molecule to a different `Docker`_ socket than the default
126               ``unix:///var/run/docker.sock``. ``tcp``, ``fd`` and ``ssh``
127               socket types can be configured. For details, please reference
128               `Docker daemon socket options`_.
129 
130     .. code-block:: yaml
131 
132         platforms:
133         - name: instance
134           image: centos:7
135           privileged: true
136           volumes:
137             - "/sys/fs/cgroup:/sys/fs/cgroup:rw"
138           command: "/usr/sbin/init"
139           tty: True
140           environment:
141             container: docker
142 
143     .. code-block:: bash
144 
145         $ pip install molecule[docker]
146 
147     When pulling from a private registry, it is the user's discretion to decide
148     whether to use hard-code strings or environment variables for passing
149     credentials to molecule.
150 
151     .. important::
152 
153         Hard-coded credentials in ``molecule.yml`` should be avoided, instead use
154         `variable substitution`_.
155 
156     Provide a list of files Molecule will preserve, relative to the scenario
157     ephemeral directory, after any ``destroy`` subcommand execution.
158 
159     .. code-block:: yaml
160 
161         driver:
162           name: docker
163           safe_files:
164             - foo
165 
166     .. _`Docker`: https://www.docker.com
167     .. _`systemd`: https://www.freedesktop.org/wiki/Software/systemd/
168     .. _`CMD`: https://docs.docker.com/engine/reference/builder/#cmd
169     """  # noqa
170 
171     def __init__(self, config=None):
172         super(Docker, self).__init__(config)
173         self._name = 'docker'
174 
175     @property
176     def name(self):
177         return self._name
178 
179     @name.setter
180     def name(self, value):
181         self._name = value
182 
183     @property
184     def login_cmd_template(self):
185         return (
186             'docker exec '
187             '-e COLUMNS={columns} '
188             '-e LINES={lines} '
189             '-e TERM=bash '
190             '-e TERM=xterm '
191             '-ti {instance} bash'
192         )
193 
194     @property
195     def default_safe_files(self):
196         return [os.path.join(self._config.scenario.ephemeral_directory, 'Dockerfile')]
197 
198     @property
199     def default_ssh_connection_options(self):
200         return []
201 
202     def login_options(self, instance_name):
203         return {'instance': instance_name}
204 
205     def ansible_connection_options(self, instance_name):
206         return {'ansible_connection': 'docker'}
207 
208     @lru_cache()
209     def sanity_checks(self):
210         """Implement Docker driver sanity checks."""
211 
212         log.info("Sanity checks: '{}'".format(self._name))
213 
214         try:
215             # ansible >= 2.8
216             from ansible.module_utils.docker.common import HAS_DOCKER_PY
217         except ImportError:
218             # ansible < 2.8
219             from ansible.module_utils.docker_common import HAS_DOCKER_PY
220 
221         if not HAS_DOCKER_PY:
222             msg = (
223                 'Missing Docker driver dependency. Please '
224                 "install via 'molecule[docker]' or refer to "
225                 'your INSTALL.rst driver documentation file'
226             )
227             sysexit_with_message(msg)
228 
229         try:
230             import docker
231             import requests
232 
233             docker_client = docker.from_env()
234             docker_client.ping()
235         except requests.exceptions.ConnectionError:
236             msg = (
237                 'Unable to contact the Docker daemon. '
238                 'Please refer to https://docs.docker.com/config/daemon/ '
239                 'for managing the daemon'
240             )
241             sysexit_with_message(msg)
242
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/molecule/driver/docker.py b/molecule/driver/docker.py
--- a/molecule/driver/docker.py
+++ b/molecule/driver/docker.py
@@ -67,6 +67,8 @@
             privileged: True|False
             security_opts:
               - seccomp=unconfined
+            devices:
+              - /dev/fuse:/dev/fuse:rwm
             volumes:
               - /sys/fs/cgroup:/sys/fs/cgroup:ro
             keep_volumes: True|False

{"golden_diff": "diff --git a/molecule/driver/docker.py b/molecule/driver/docker.py\n--- a/molecule/driver/docker.py\n+++ b/molecule/driver/docker.py\n@@ -67,6 +67,8 @@\n             privileged: True|False\n             security_opts:\n               - seccomp=unconfined\n+            devices:\n+              - /dev/fuse:/dev/fuse:rwm\n             volumes:\n               - /sys/fs/cgroup:/sys/fs/cgroup:ro\n             keep_volumes: True|False\n", "issue": "\"devices\" support in docker driver\n# Issue Type\r\n\r\n- Feature request\r\n\r\n# Molecule and Ansible details\r\n\r\n```\r\n$ ansible --version && molecule --version\r\nansible 2.8.5\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = ['/home/sylvain/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /home/sylvain/venv/molecule/lib/python3.6/site-packages/ansible\r\n  executable location = /home/sylvain/venv/molecule/bin/ansible\r\n  python version = 3.6.8 (default, Aug 20 2019, 17:12:48) [GCC 8.3.0]\r\nmolecule, version 2.22\r\n```\r\n\r\nMolecule installation method (one of):\r\n\r\n- pip\r\n\r\nAnsible installation method (one of):\r\n\r\n- pip\r\n\r\n# Desired Behavior\r\n\r\nThe docker driver does not support the `devices` option available in the `docker_container` ansible module, so we can't test roles that are using fuse for example, except by using `privileged` option which is quite dangerous. Can you please support for this option?\r\n\n\"devices\" support in docker driver\n# Issue Type\r\n\r\n- Feature request\r\n\r\n# Molecule and Ansible details\r\n\r\n```\r\n$ ansible --version && molecule --version\r\nansible 2.8.5\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = ['/home/sylvain/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /home/sylvain/venv/molecule/lib/python3.6/site-packages/ansible\r\n  executable location = /home/sylvain/venv/molecule/bin/ansible\r\n  python version = 3.6.8 (default, Aug 20 2019, 17:12:48) [GCC 8.3.0]\r\nmolecule, version 2.22\r\n```\r\n\r\nMolecule installation method (one of):\r\n\r\n- pip\r\n\r\nAnsible installation method (one of):\r\n\r\n- pip\r\n\r\n# Desired Behavior\r\n\r\nThe docker driver does not support the `devices` option available in the `docker_container` ansible module, so we can't test roles that are using fuse for example, except by using `privileged` option which is quite dangerous. Can you please support for this option?\r\n\n", "before_files": [{"content": "#  Copyright (c) 2015-2018 Cisco Systems, Inc.\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to\n#  deal in the Software without restriction, including without limitation the\n#  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n#  sell copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n#  DEALINGS IN THE SOFTWARE.\n\nfrom __future__ import absolute_import\n\nimport os\n\nfrom molecule import logger\nfrom molecule.api import Driver\nfrom molecule.util import lru_cache\nfrom molecule.util import sysexit_with_message\n\nlog = logger.get_logger(__name__)\n\n\nclass Docker(Driver):\n    \"\"\"\n    The class responsible for managing `Docker`_ containers.  `Docker`_ is\n    the default driver used in Molecule.\n\n    Molecule leverages Ansible's `docker_container`_ module, by mapping\n    variables from ``molecule.yml`` into ``create.yml`` and ``destroy.yml``.\n\n    .. _`docker_container`: https://docs.ansible.com/ansible/latest/docker_container_module.html\n    .. _`Docker Security Configuration`: https://docs.docker.com/engine/reference/run/#security-configuration\n    .. _`Docker daemon socket options`: https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-socket-option\n\n    .. code-block:: yaml\n\n        driver:\n          name: docker\n        platforms:\n          - name: instance\n            hostname: instance\n            image: image_name:tag\n            dockerfile: Dockerfile.j2\n            pull: True|False\n            pre_build_image: True|False\n            registry:\n              url: registry.example.com\n              credentials:\n                username: $USERNAME\n                password: $PASSWORD\n                email: user@example.com\n                user: root\n            override_command: True|False\n            command: sleep infinity\n            tty: True|False\n            pid_mode: host\n            privileged: True|False\n            security_opts:\n              - seccomp=unconfined\n            volumes:\n              - /sys/fs/cgroup:/sys/fs/cgroup:ro\n            keep_volumes: True|False\n            tmpfs:\n              - /tmp\n              - /run\n            capabilities:\n              - SYS_ADMIN\n            sysctls:\n              net.core.somaxconn: 1024\n              net.ipv4.tcp_syncookies: 0\n            exposed_ports:\n              - 53/udp\n              - 53/tcp\n            published_ports:\n              - 0.0.0.0:8053:53/udp\n              - 0.0.0.0:8053:53/tcp\n            ulimits:\n              - nofile:262144:262144\n            dns_servers:\n              - 8.8.8.8\n            etc_hosts: \"{'host1.example.com': '10.3.1.5'}\"\n            networks:\n              - name: foo\n              - name: bar\n            network_mode: host\n            purge_networks: true\n            docker_host: tcp://localhost:12376\n            cacert_path: /foo/bar/ca.pem\n            cert_path: /foo/bar/cert.pem\n            key_path: /foo/bar/key.pem\n            tls_verify: true\n            env:\n              FOO: bar\n            restart_policy: on-failure\n            restart_retries: 1\n            buildargs:\n                http_proxy: http://proxy.example.com:8080/\n\n    If specifying the `CMD`_ directive in your ``Dockerfile.j2`` or consuming a\n    built image which declares a ``CMD`` directive, then you must set\n    ``override_command: False``. Otherwise, Molecule takes care to honour the\n    value of the ``command`` key or uses the default of ``bash -c \"while true;\n    do sleep 10000; done\"`` to run the container until it is provisioned.\n\n    When attempting to utilize a container image with `systemd`_ as your init\n    system inside the container to simulate a real machine, make sure to set\n    the ``privileged``, ``volumes``, ``command``, and ``environment``\n    values. An example using the ``centos:7`` image is below:\n\n    .. note:: Do note that running containers in privileged mode is considerably\n              less secure. For details, please reference `Docker Security\n              Configuration`_\n\n    .. note:: With the environment variable ``DOCKER_HOST`` the user can bind\n              Molecule to a different `Docker`_ socket than the default\n              ``unix:///var/run/docker.sock``. ``tcp``, ``fd`` and ``ssh``\n              socket types can be configured. For details, please reference\n              `Docker daemon socket options`_.\n\n    .. code-block:: yaml\n\n        platforms:\n        - name: instance\n          image: centos:7\n          privileged: true\n          volumes:\n            - \"/sys/fs/cgroup:/sys/fs/cgroup:rw\"\n          command: \"/usr/sbin/init\"\n          tty: True\n          environment:\n            container: docker\n\n    .. code-block:: bash\n\n        $ pip install molecule[docker]\n\n    When pulling from a private registry, it is the user's discretion to decide\n    whether to use hard-code strings or environment variables for passing\n    credentials to molecule.\n\n    .. important::\n\n        Hard-coded credentials in ``molecule.yml`` should be avoided, instead use\n        `variable substitution`_.\n\n    Provide a list of files Molecule will preserve, relative to the scenario\n    ephemeral directory, after any ``destroy`` subcommand execution.\n\n    .. code-block:: yaml\n\n        driver:\n          name: docker\n          safe_files:\n            - foo\n\n    .. _`Docker`: https://www.docker.com\n    .. _`systemd`: https://www.freedesktop.org/wiki/Software/systemd/\n    .. _`CMD`: https://docs.docker.com/engine/reference/builder/#cmd\n    \"\"\"  # noqa\n\n    def __init__(self, config=None):\n        super(Docker, self).__init__(config)\n        self._name = 'docker'\n\n    @property\n    def name(self):\n        return self._name\n\n    @name.setter\n    def name(self, value):\n        self._name = value\n\n    @property\n    def login_cmd_template(self):\n        return (\n            'docker exec '\n            '-e COLUMNS={columns} '\n            '-e LINES={lines} '\n            '-e TERM=bash '\n            '-e TERM=xterm '\n            '-ti {instance} bash'\n        )\n\n    @property\n    def default_safe_files(self):\n        return [os.path.join(self._config.scenario.ephemeral_directory, 'Dockerfile')]\n\n    @property\n    def default_ssh_connection_options(self):\n        return []\n\n    def login_options(self, instance_name):\n        return {'instance': instance_name}\n\n    def ansible_connection_options(self, instance_name):\n        return {'ansible_connection': 'docker'}\n\n    @lru_cache()\n    def sanity_checks(self):\n        \"\"\"Implement Docker driver sanity checks.\"\"\"\n\n        log.info(\"Sanity checks: '{}'\".format(self._name))\n\n        try:\n            # ansible >= 2.8\n            from ansible.module_utils.docker.common import HAS_DOCKER_PY\n        except ImportError:\n            # ansible < 2.8\n            from ansible.module_utils.docker_common import HAS_DOCKER_PY\n\n        if not HAS_DOCKER_PY:\n            msg = (\n                'Missing Docker driver dependency. Please '\n                \"install via 'molecule[docker]' or refer to \"\n                'your INSTALL.rst driver documentation file'\n            )\n            sysexit_with_message(msg)\n\n        try:\n            import docker\n            import requests\n\n            docker_client = docker.from_env()\n            docker_client.ping()\n        except requests.exceptions.ConnectionError:\n            msg = (\n                'Unable to contact the Docker daemon. '\n                'Please refer to https://docs.docker.com/config/daemon/ '\n                'for managing the daemon'\n            )\n            sysexit_with_message(msg)\n", "path": "molecule/driver/docker.py"}], "after_files": [{"content": "#  Copyright (c) 2015-2018 Cisco Systems, Inc.\n#\n#  Permission is hereby granted, free of charge, to any person obtaining a copy\n#  of this software and associated documentation files (the \"Software\"), to\n#  deal in the Software without restriction, including without limitation the\n#  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n#  sell copies of the Software, and to permit persons to whom the Software is\n#  furnished to do so, subject to the following conditions:\n#\n#  The above copyright notice and this permission notice shall be included in\n#  all copies or substantial portions of the Software.\n#\n#  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n#  DEALINGS IN THE SOFTWARE.\n\nfrom __future__ import absolute_import\n\nimport os\n\nfrom molecule import logger\nfrom molecule.api import Driver\nfrom molecule.util import lru_cache\nfrom molecule.util import sysexit_with_message\n\nlog = logger.get_logger(__name__)\n\n\nclass Docker(Driver):\n    \"\"\"\n    The class responsible for managing `Docker`_ containers.  `Docker`_ is\n    the default driver used in Molecule.\n\n    Molecule leverages Ansible's `docker_container`_ module, by mapping\n    variables from ``molecule.yml`` into ``create.yml`` and ``destroy.yml``.\n\n    .. _`docker_container`: https://docs.ansible.com/ansible/latest/docker_container_module.html\n    .. _`Docker Security Configuration`: https://docs.docker.com/engine/reference/run/#security-configuration\n    .. _`Docker daemon socket options`: https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-socket-option\n\n    .. code-block:: yaml\n\n        driver:\n          name: docker\n        platforms:\n          - name: instance\n            hostname: instance\n            image: image_name:tag\n            dockerfile: Dockerfile.j2\n            pull: True|False\n            pre_build_image: True|False\n            registry:\n              url: registry.example.com\n              credentials:\n                username: $USERNAME\n                password: $PASSWORD\n                email: user@example.com\n                user: root\n            override_command: True|False\n            command: sleep infinity\n            tty: True|False\n            pid_mode: host\n            privileged: True|False\n            security_opts:\n              - seccomp=unconfined\n            devices:\n              - /dev/fuse:/dev/fuse:rwm\n            volumes:\n              - /sys/fs/cgroup:/sys/fs/cgroup:ro\n            keep_volumes: True|False\n            tmpfs:\n              - /tmp\n              - /run\n            capabilities:\n              - SYS_ADMIN\n            sysctls:\n              net.core.somaxconn: 1024\n              net.ipv4.tcp_syncookies: 0\n            exposed_ports:\n              - 53/udp\n              - 53/tcp\n            published_ports:\n              - 0.0.0.0:8053:53/udp\n              - 0.0.0.0:8053:53/tcp\n            ulimits:\n              - nofile:262144:262144\n            dns_servers:\n              - 8.8.8.8\n            etc_hosts: \"{'host1.example.com': '10.3.1.5'}\"\n            networks:\n              - name: foo\n              - name: bar\n            network_mode: host\n            purge_networks: true\n            docker_host: tcp://localhost:12376\n            cacert_path: /foo/bar/ca.pem\n            cert_path: /foo/bar/cert.pem\n            key_path: /foo/bar/key.pem\n            tls_verify: true\n            env:\n              FOO: bar\n            restart_policy: on-failure\n            restart_retries: 1\n            buildargs:\n                http_proxy: http://proxy.example.com:8080/\n\n    If specifying the `CMD`_ directive in your ``Dockerfile.j2`` or consuming a\n    built image which declares a ``CMD`` directive, then you must set\n    ``override_command: False``. Otherwise, Molecule takes care to honour the\n    value of the ``command`` key or uses the default of ``bash -c \"while true;\n    do sleep 10000; done\"`` to run the container until it is provisioned.\n\n    When attempting to utilize a container image with `systemd`_ as your init\n    system inside the container to simulate a real machine, make sure to set\n    the ``privileged``, ``volumes``, ``command``, and ``environment``\n    values. An example using the ``centos:7`` image is below:\n\n    .. note:: Do note that running containers in privileged mode is considerably\n              less secure. For details, please reference `Docker Security\n              Configuration`_\n\n    .. note:: With the environment variable ``DOCKER_HOST`` the user can bind\n              Molecule to a different `Docker`_ socket than the default\n              ``unix:///var/run/docker.sock``. ``tcp``, ``fd`` and ``ssh``\n              socket types can be configured. For details, please reference\n              `Docker daemon socket options`_.\n\n    .. code-block:: yaml\n\n        platforms:\n        - name: instance\n          image: centos:7\n          privileged: true\n          volumes:\n            - \"/sys/fs/cgroup:/sys/fs/cgroup:rw\"\n          command: \"/usr/sbin/init\"\n          tty: True\n          environment:\n            container: docker\n\n    .. code-block:: bash\n\n        $ pip install molecule[docker]\n\n    When pulling from a private registry, it is the user's discretion to decide\n    whether to use hard-code strings or environment variables for passing\n    credentials to molecule.\n\n    .. important::\n\n        Hard-coded credentials in ``molecule.yml`` should be avoided, instead use\n        `variable substitution`_.\n\n    Provide a list of files Molecule will preserve, relative to the scenario\n    ephemeral directory, after any ``destroy`` subcommand execution.\n\n    .. code-block:: yaml\n\n        driver:\n          name: docker\n          safe_files:\n            - foo\n\n    .. _`Docker`: https://www.docker.com\n    .. _`systemd`: https://www.freedesktop.org/wiki/Software/systemd/\n    .. _`CMD`: https://docs.docker.com/engine/reference/builder/#cmd\n    \"\"\"  # noqa\n\n    def __init__(self, config=None):\n        super(Docker, self).__init__(config)\n        self._name = 'docker'\n\n    @property\n    def name(self):\n        return self._name\n\n    @name.setter\n    def name(self, value):\n        self._name = value\n\n    @property\n    def login_cmd_template(self):\n        return (\n            'docker exec '\n            '-e COLUMNS={columns} '\n            '-e LINES={lines} '\n            '-e TERM=bash '\n            '-e TERM=xterm '\n            '-ti {instance} bash'\n        )\n\n    @property\n    def default_safe_files(self):\n        return [os.path.join(self._config.scenario.ephemeral_directory, 'Dockerfile')]\n\n    @property\n    def default_ssh_connection_options(self):\n        return []\n\n    def login_options(self, instance_name):\n        return {'instance': instance_name}\n\n    def ansible_connection_options(self, instance_name):\n        return {'ansible_connection': 'docker'}\n\n    @lru_cache()\n    def sanity_checks(self):\n        \"\"\"Implement Docker driver sanity checks.\"\"\"\n\n        log.info(\"Sanity checks: '{}'\".format(self._name))\n\n        try:\n            # ansible >= 2.8\n            from ansible.module_utils.docker.common import HAS_DOCKER_PY\n        except ImportError:\n            # ansible < 2.8\n            from ansible.module_utils.docker_common import HAS_DOCKER_PY\n\n        if not HAS_DOCKER_PY:\n            msg = (\n                'Missing Docker driver dependency. Please '\n                \"install via 'molecule[docker]' or refer to \"\n                'your INSTALL.rst driver documentation file'\n            )\n            sysexit_with_message(msg)\n\n        try:\n            import docker\n            import requests\n\n            docker_client = docker.from_env()\n            docker_client.ping()\n        except requests.exceptions.ConnectionError:\n            msg = (\n                'Unable to contact the Docker daemon. '\n                'Please refer to https://docs.docker.com/config/daemon/ '\n                'for managing the daemon'\n            )\n            sysexit_with_message(msg)\n", "path": "molecule/driver/docker.py"}]}