Skip to content

Commit 986a14a

Browse files
authored
Merge pull request #1108 from docker/1107-link-local-ips
Add support for link-local IPs in endpoint config
2 parents 9010d59 + 0de366d commit 986a14a

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

docker/api/network.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ def inspect_network(self, net_id):
6060
@minimum_version('1.21')
6161
def connect_container_to_network(self, container, net_id,
6262
ipv4_address=None, ipv6_address=None,
63-
aliases=None, links=None):
63+
aliases=None, links=None,
64+
link_local_ips=None):
6465
data = {
6566
"Container": container,
6667
"EndpointConfig": self.create_endpoint_config(
6768
aliases=aliases, links=links, ipv4_address=ipv4_address,
68-
ipv6_address=ipv6_address
69+
ipv6_address=ipv6_address, link_local_ips=link_local_ips
6970
),
7071
}
7172

docker/utils/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,8 @@ def create_networking_config(endpoints_config=None):
873873

874874

875875
def create_endpoint_config(version, aliases=None, links=None,
876-
ipv4_address=None, ipv6_address=None):
876+
ipv4_address=None, ipv6_address=None,
877+
link_local_ips=None):
877878
if version_lt(version, '1.22'):
878879
raise errors.InvalidVersion(
879880
'Endpoint config is not supported for API version < 1.22'
@@ -896,6 +897,13 @@ def create_endpoint_config(version, aliases=None, links=None,
896897
if ipam_config:
897898
endpoint_config['IPAMConfig'] = ipam_config
898899

900+
if link_local_ips is not None:
901+
if version_lt(version, '1.24'):
902+
raise errors.InvalidVersion(
903+
'link_local_ips is not supported for API version < 1.24'
904+
)
905+
endpoint_config['LinkLocalIPs'] = link_local_ips
906+
899907
return endpoint_config
900908

901909

docs/api.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ Connect a container to a network.
179179

180180
* container (str): container-id/name to be connected to the network
181181
* net_id (str): network id
182+
* aliases (list): A list of aliases for this endpoint. Names in that list can
183+
be used within the network to reach the container. Defaults to `None`.
184+
* links (list): A list of links for this endpoint. Containers declared in this
185+
list will be [linked](https://docs.docker.com/engine/userguide/networking/work-with-networks/#linking-containers-in-user-defined-networks)
186+
to this container. Defaults to `None`.
187+
* ipv4_address (str): The IP address of this container on the network,
188+
using the IPv4 protocol. Defaults to `None`.
189+
* ipv6_address (str): The IP address of this container on the network,
190+
using the IPv6 protocol. Defaults to `None`.
191+
* link_local_ips (list): A list of link-local (IPv4/IPv6) addresses.
182192

183193
## copy
184194
Identical to the `docker cp` command. Get files/folders from the container.

docs/networks.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Create an endpoint config dictionary to be used with
107107
using the IPv4 protocol. Defaults to `None`.
108108
* ipv6_address (str): The IP address of this container on the network,
109109
using the IPv6 protocol. Defaults to `None`.
110+
* link_local_ips (list): A list of link-local (IPv4/IPv6) addresses.
110111

111112
**Returns** An endpoint config dictionary.
112113

0 commit comments

Comments
 (0)