mirror of https://github.com/docker/docker-py.git
Add ability to set 'Hostname' on a Service.
Signed-off-by: Nils Krabshuis <nils.krabshuis@redwood.com>
This commit is contained in:
parent
b791aa10fa
commit
44c31e47e0
|
@ -96,6 +96,7 @@ class ServiceCollection(Collection):
|
||||||
access and load balance a service. Default: ``None``.
|
access and load balance a service. Default: ``None``.
|
||||||
env (list of str): Environment variables, in the form
|
env (list of str): Environment variables, in the form
|
||||||
``KEY=val``.
|
``KEY=val``.
|
||||||
|
hostname (string): Hostname to set on the container.
|
||||||
labels (dict): Labels to apply to the service.
|
labels (dict): Labels to apply to the service.
|
||||||
log_driver (str): Log driver to use for containers.
|
log_driver (str): Log driver to use for containers.
|
||||||
log_driver_options (dict): Log driver options.
|
log_driver_options (dict): Log driver options.
|
||||||
|
@ -176,6 +177,7 @@ CONTAINER_SPEC_KWARGS = [
|
||||||
'command',
|
'command',
|
||||||
'args',
|
'args',
|
||||||
'env',
|
'env',
|
||||||
|
'hostname',
|
||||||
'workdir',
|
'workdir',
|
||||||
'user',
|
'user',
|
||||||
'labels',
|
'labels',
|
||||||
|
|
|
@ -70,6 +70,7 @@ class ContainerSpec(dict):
|
||||||
image (string): The image name to use for the container.
|
image (string): The image name to use for the container.
|
||||||
command (string or list): The command to be run in the image.
|
command (string or list): The command to be run in the image.
|
||||||
args (:py:class:`list`): Arguments to the command.
|
args (:py:class:`list`): Arguments to the command.
|
||||||
|
hostname (string): The hostname to set on the container.
|
||||||
env (dict): Environment variables.
|
env (dict): Environment variables.
|
||||||
dir (string): The working directory for commands to run in.
|
dir (string): The working directory for commands to run in.
|
||||||
user (string): The user inside the container.
|
user (string): The user inside the container.
|
||||||
|
@ -82,9 +83,9 @@ class ContainerSpec(dict):
|
||||||
secrets (list of py:class:`SecretReference`): List of secrets to be
|
secrets (list of py:class:`SecretReference`): List of secrets to be
|
||||||
made available inside the containers.
|
made available inside the containers.
|
||||||
"""
|
"""
|
||||||
def __init__(self, image, command=None, args=None, env=None, workdir=None,
|
def __init__(self, image, command=None, args=None, hostname=None, env=None,
|
||||||
user=None, labels=None, mounts=None, stop_grace_period=None,
|
workdir=None, user=None, labels=None, mounts=None,
|
||||||
secrets=None):
|
stop_grace_period=None, secrets=None):
|
||||||
self['Image'] = image
|
self['Image'] = image
|
||||||
|
|
||||||
if isinstance(command, six.string_types):
|
if isinstance(command, six.string_types):
|
||||||
|
@ -92,6 +93,8 @@ class ContainerSpec(dict):
|
||||||
self['Command'] = command
|
self['Command'] = command
|
||||||
self['Args'] = args
|
self['Args'] = args
|
||||||
|
|
||||||
|
if hostname is not None:
|
||||||
|
self['Hostname'] = hostname
|
||||||
if env is not None:
|
if env is not None:
|
||||||
if isinstance(env, dict):
|
if isinstance(env, dict):
|
||||||
self['Env'] = format_environment(env)
|
self['Env'] = format_environment(env)
|
||||||
|
|
|
@ -9,6 +9,7 @@ class CreateServiceKwargsTest(unittest.TestCase):
|
||||||
'command': 'true',
|
'command': 'true',
|
||||||
'name': 'somename',
|
'name': 'somename',
|
||||||
'labels': {'key': 'value'},
|
'labels': {'key': 'value'},
|
||||||
|
'hostname': 'test_host',
|
||||||
'mode': 'global',
|
'mode': 'global',
|
||||||
'update_config': {'update': 'config'},
|
'update_config': {'update': 'config'},
|
||||||
'networks': ['somenet'],
|
'networks': ['somenet'],
|
||||||
|
@ -47,6 +48,6 @@ class CreateServiceKwargsTest(unittest.TestCase):
|
||||||
'Options': {'foo': 'bar'}
|
'Options': {'foo': 'bar'}
|
||||||
}
|
}
|
||||||
assert set(task_template['ContainerSpec'].keys()) == set([
|
assert set(task_template['ContainerSpec'].keys()) == set([
|
||||||
'Image', 'Command', 'Args', 'Env', 'Dir', 'User', 'Labels',
|
'Image', 'Command', 'Args', 'Hostname', 'Env', 'Dir', 'User',
|
||||||
'Mounts', 'StopGracePeriod'
|
'Labels', 'Mounts', 'StopGracePeriod'
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in New Issue