this to determine the location of the Memory value depending on the version used.
In v1.18 and earlier it was ['Config']['Memory'], but in v1.19 it
changed to ['HostConfig']['Memory'].
This is mlosev's patch (from #1208), rebased against devel as of
2790af2. It resolves#1707, which was caused by an API incompatibility
between the docker module and server API version 1.19.
There was a catch-all `except` statement in `create_containers`:
try:
containers = do_create(count, params)
except:
self.pull_image()
containers = do_create(count, params)
This would mask a variety of errors that should be exposed, including
API compatability errors (as in #1707) and common Python exceptions (KeyError, ValueError, etc) that could result from errors in the code.
This change makes the `except` statement more specific, and only attempts to pull the image and start a container if the original create attempt failed due to a 404 error from the docker API.
The `docker` Python module only accepts `None` or `'host'` as arguments.
This makes it difficult to conditionally set the `pid` attribute using
standard Ansible syntax.
This change converts any value that evaluates as boolean `False` to
`None`, which includes empty strings:
pid:
As well as an explicit `false`:
pid: false
This permits the following to work as intended:
- hosts: localhost
tasks:
- name: starting container
docker:
docker_api_version: 1.18
image: larsks/mini-httpd
name: web
pid: "{{ container_pid|default('') }}"
If `container_pid` is set to `host` somewhere, this will create a
Docker container with `pid=host`; otherwise, this will create a
container with normal isolated pid namespace.
If `docker.__version__` contains non-digit characters, such as:
>>> import docker
>>> docker.__version__
'1.4.0-dev'
Then `get_docker_py_versioninfo` will fail with:
ValueError: invalid literal for int() with base 10: '0-de'
This patch corrects the parsing of the version string so that
`get_docker_py_versioninfo` in this example would return:
(1, 4, 0, '-dev')
port mapping with this module only works for ports that are exposed either in the Dockerfile or via an additional arguments. This is different from the command line docker client, that is willing to also map ports that are not exposed.
This comments makes the behaviour more obvious.