Skip to content

Commit d4b1c25

Browse files
committed
Update links docs and fix bug in normalize_links
Signed-off-by: Joffrey F <[email protected]>
1 parent 049e7e1 commit d4b1c25

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

docker/api/container.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,11 @@ def create_host_config(self, *args, **kwargs):
473473
signals and reaps processes
474474
init_path (str): Path to the docker-init binary
475475
ipc_mode (str): Set the IPC mode for the container.
476-
isolation (str): Isolation technology to use. Default: `None`.
477-
links (dict or list of tuples): Either a dictionary mapping name
478-
to alias or as a list of ``(name, alias)`` tuples.
476+
isolation (str): Isolation technology to use. Default: ``None``.
477+
links (dict): Mapping of links using the
478+
``{'container': 'alias'}`` format. The alias is optional.
479+
Containers declared in this dict will be linked to the new
480+
container using the provided alias. Default: ``None``.
479481
log_config (LogConfig): Logging configuration
480482
lxc_conf (dict): LXC config.
481483
mem_limit (float or str): Memory limit. Accepts float values
@@ -605,9 +607,10 @@ def create_endpoint_config(self, *args, **kwargs):
605607
aliases (:py:class:`list`): A list of aliases for this endpoint.
606608
Names in that list can be used within the network to reach the
607609
container. Defaults to ``None``.
608-
links (:py:class:`list`): A list of links for this endpoint.
609-
Containers declared in this list will be linked to this
610-
container. Defaults to ``None``.
610+
links (dict): Mapping of links for this endpoint using the
611+
``{'container': 'alias'}`` format. The alias is optional.
612+
Containers declared in this dict will be linked to this
613+
container using the provided alias. Defaults to ``None``.
611614
ipv4_address (str): The IP address of this container on the
612615
network, using the IPv4 protocol. Defaults to ``None``.
613616
ipv6_address (str): The IP address of this container on the
@@ -622,7 +625,7 @@ def create_endpoint_config(self, *args, **kwargs):
622625
623626
>>> endpoint_config = client.create_endpoint_config(
624627
aliases=['web', 'app'],
625-
links=['app_db'],
628+
links={'app_db': 'db', 'another': None},
626629
ipv4_address='132.65.0.123'
627630
)
628631

docker/models/containers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,10 @@ def run(self, image, command=None, stdout=True, stderr=False,
574574
``{"label1": "value1", "label2": "value2"}``) or a list of
575575
names of labels to set with empty values (e.g.
576576
``["label1", "label2"]``)
577-
links (dict or list of tuples): Either a dictionary mapping name
578-
to alias or as a list of ``(name, alias)`` tuples.
577+
links (dict): Mapping of links using the
578+
``{'container': 'alias'}`` format. The alias is optional.
579+
Containers declared in this dict will be linked to the new
580+
container using the provided alias. Default: ``None``.
579581
log_config (LogConfig): Logging configuration.
580582
mac_address (str): MAC address to assign to the container.
581583
mem_limit (int or str): Memory limit. Accepts float values

docker/utils/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def normalize_links(links):
441441
if isinstance(links, dict):
442442
links = six.iteritems(links)
443443

444-
return ['{0}:{1}'.format(k, v) for k, v in sorted(links)]
444+
return ['{0}:{1}'.format(k, v) if v else k for k, v in sorted(links)]
445445

446446

447447
def parse_env_file(env_file):

0 commit comments

Comments
 (0)