docker: make docker-exec the default execution driver

Docker 1.13.1 removed the ExecutionDriver from the ``docker info``
return data. This causes all attempts to run commands in containers to
fall back to the old lxc-attach driver, which is incompatible with newer
docker releases.
This commit is contained in:
Erik Johnson 2017-02-18 19:47:36 -06:00
parent a6a17d58aa
commit cbd0270bac

View file

@ -203,6 +203,14 @@ Functions
Executing Commands Within a Running Container
---------------------------------------------
.. note::
With the release of Docker 1.13.1, the Execution Driver has been removed.
Starting in versions 2016.3.6, 2016.11.4, and Nitrogen, Salt defaults to
using ``docker exec`` to run commands in containers, however for older Salt
releases it will be necessary to set the ``docker.exec_driver`` config
option to either ``docker-exec`` or ``nsenter`` for Docker versions 1.13.1
and newer.
Multiple methods exist for executing commands within Docker containers:
- lxc-attach_: Default for older versions of docker
@ -843,10 +851,12 @@ def _get_exec_driver():
__context__[contextkey] = from_config
return from_config
# For old versions of docker, lxc was the only supported driver.
# This is a sane default.
driver = info().get('ExecutionDriver', 'lxc-')
if driver.startswith('lxc-'):
# The execution driver was removed in Docker 1.13.1, docker-exec is now
# the default.
driver = info().get('ExecutionDriver', 'docker-exec')
if driver == 'docker-exec':
__context__[contextkey] = driver
elif driver.startswith('lxc-'):
__context__[contextkey] = 'lxc-attach'
elif driver.startswith('native-') and HAS_NSENTER:
__context__[contextkey] = 'nsenter'
@ -5510,9 +5520,7 @@ def get_client_args():
.. versionadded:: 2016.3.6,2016.11.4,Nitrogen
Returns the args for docker-py's `low-level API`_, organized by container
config, host config, and networking config. This is designed for use by the
:mod:`docker states <salt.states.docker>` to more gracefully handle API
changes.
config, host config, and networking config.
.. _`low-level API`: http://docker-py.readthedocs.io/en/stable/api.html