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``.
|
||||
env (list of str): Environment variables, in the form
|
||||
``KEY=val``.
|
||||
hostname (string): Hostname to set on the container.
|
||||
labels (dict): Labels to apply to the service.
|
||||
log_driver (str): Log driver to use for containers.
|
||||
log_driver_options (dict): Log driver options.
|
||||
|
@ -176,6 +177,7 @@ CONTAINER_SPEC_KWARGS = [
|
|||
'command',
|
||||
'args',
|
||||
'env',
|
||||
'hostname',
|
||||
'workdir',
|
||||
'user',
|
||||
'labels',
|
||||
|
|
|
@ -70,6 +70,7 @@ class ContainerSpec(dict):
|
|||
image (string): The image name to use for the container.
|
||||
command (string or list): The command to be run in the image.
|
||||
args (:py:class:`list`): Arguments to the command.
|
||||
hostname (string): The hostname to set on the container.
|
||||
env (dict): Environment variables.
|
||||
dir (string): The working directory for commands to run in.
|
||||
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
|
||||
made available inside the containers.
|
||||
"""
|
||||
def __init__(self, image, command=None, args=None, env=None, workdir=None,
|
||||
user=None, labels=None, mounts=None, stop_grace_period=None,
|
||||
secrets=None):
|
||||
def __init__(self, image, command=None, args=None, hostname=None, env=None,
|
||||
workdir=None, user=None, labels=None, mounts=None,
|
||||
stop_grace_period=None, secrets=None):
|
||||
self['Image'] = image
|
||||
|
||||
if isinstance(command, six.string_types):
|
||||
|
@ -92,6 +93,8 @@ class ContainerSpec(dict):
|
|||
self['Command'] = command
|
||||
self['Args'] = args
|
||||
|
||||
if hostname is not None:
|
||||
self['Hostname'] = hostname
|
||||
if env is not None:
|
||||
if isinstance(env, dict):
|
||||
self['Env'] = format_environment(env)
|
||||
|
|
|
@ -9,6 +9,7 @@ class CreateServiceKwargsTest(unittest.TestCase):
|
|||
'command': 'true',
|
||||
'name': 'somename',
|
||||
'labels': {'key': 'value'},
|
||||
'hostname': 'test_host',
|
||||
'mode': 'global',
|
||||
'update_config': {'update': 'config'},
|
||||
'networks': ['somenet'],
|
||||
|
@ -47,6 +48,6 @@ class CreateServiceKwargsTest(unittest.TestCase):
|
|||
'Options': {'foo': 'bar'}
|
||||
}
|
||||
assert set(task_template['ContainerSpec'].keys()) == set([
|
||||
'Image', 'Command', 'Args', 'Env', 'Dir', 'User', 'Labels',
|
||||
'Mounts', 'StopGracePeriod'
|
||||
'Image', 'Command', 'Args', 'Hostname', 'Env', 'Dir', 'User',
|
||||
'Labels', 'Mounts', 'StopGracePeriod'
|
||||
])
|
||||
|
|
Loading…
Reference in New Issue