@ -229,15 +229,36 @@ options:
networks :
description :
- List of networks the container belongs to .
- Each network is a dict with keys C ( name ) , C ( ipv4_address ) , C ( ipv6_address ) , C ( links ) , C ( aliases ) .
- For each network C ( name ) is required , all other keys are optional .
- If included , C ( links ) or C ( aliases ) are lists .
- For examples of the data structure and usage see EXAMPLES below .
- To remove a container from one or more networks , use the C ( purge_networks ) option .
- Note that as opposed to C ( docker run . . . ) , M ( docker_container ) does not remove the default
network if C ( networks ) is specified . You need to explicity use C ( purge_networks ) to enforce
the removal of the default network ( and all other networks not explicitly mentioned in C ( networks ) ) .
version_added : " 2.2 "
type : list
suboptions :
name :
type : str
required : true
description :
- The network ' s name.
ipv4_address :
type : str
description :
- The container ' s IPv4 address in this network.
ipv6_address :
type : str
description :
- The container ' s IPv6 address in this network.
links :
type : list
description :
- A list of containers to link to .
aliases :
type : list
description :
- List of aliases for this container in this network . These names
can be used in the network to reach this container .
oom_killer :
description :
- Whether or not to disable OOM Killer for the container .
@ -801,8 +822,6 @@ class TaskParameters(DockerBaseClass):
if self . networks :
for network in self . networks :
if not network . get ( ' name ' ) :
self . fail ( " Parameter error: network must have a name attribute. " )
network [ ' id ' ] = self . _get_network_id ( network [ ' name ' ] )
if not network [ ' id ' ] :
self . fail ( " Parameter error: network named %s could not be found. Does it exist? " % network [ ' name ' ] )
@ -1505,21 +1524,15 @@ class Container(DockerBaseClass):
diff = True
if network . get ( ' ipv6_address ' ) and network [ ' ipv6_address ' ] != connected_networks [ network [ ' name ' ] ] . get ( ' GlobalIPv6Address ' ) :
diff = True
if network . get ( ' aliases ' ) and not connected_networks [ network [ ' name ' ] ] . get ( ' Aliases ' ) :
diff = True
if network . get ( ' aliases ' ) and connected_networks [ network [ ' name ' ] ] . get ( ' Aliases ' ) :
for alias in network . get ( ' aliases ' ) :
if alias not in connected_networks [ network [ ' name ' ] ] . get ( ' Aliases ' , [ ] ) :
diff = True
if network . get ( ' links ' ) and not connected_networks [ network [ ' name ' ] ] . get ( ' Links ' ) :
diff = True
if network . get ( ' links ' ) and connected_networks [ network [ ' name ' ] ] . get ( ' Links ' ) :
if network . get ( ' aliases ' ) :
if not compare_generic ( network [ ' aliases ' ] , connected_networks [ network [ ' name ' ] ] . get ( ' Aliases ' ) , ' allow_more_present ' , ' set ' ) :
diff = True
if network . get ( ' links ' ) :
expected_links = [ ]
for link , alias in network [ ' links ' ] :
expected_links . append ( " %s : %s " % ( link , alias ) )
for link in expected_links :
if link not in connected_networks [ network [ ' name ' ] ] . get ( ' Links ' , [ ] ) :
diff = True
if not compare_generic ( expected_links , connected_networks [ network [ ' name ' ] ] . get ( ' Links ' ) , ' allow_more_present ' , ' set ' ) :
diff = True
if diff :
different = True
differences . append ( dict (
@ -2301,8 +2314,8 @@ def main():
argument_spec = dict (
auto_remove = dict ( type = ' bool ' , default = False ) ,
blkio_weight = dict ( type = ' int ' ) ,
capabilities = dict ( type = ' list ' ),
cap_drop = dict ( type = ' list ' ),
capabilities = dict ( type = ' list ' , elements = ' str ' ),
cap_drop = dict ( type = ' list ' , elements = ' str ' ),
cleanup = dict ( type = ' bool ' , default = False ) ,
command = dict ( type = ' raw ' ) ,
cpu_period = dict ( type = ' int ' ) ,
@ -2311,18 +2324,18 @@ def main():
cpuset_mems = dict ( type = ' str ' ) ,
cpu_shares = dict ( type = ' int ' ) ,
detach = dict ( type = ' bool ' , default = True ) ,
devices = dict ( type = ' list ' ),
dns_servers = dict ( type = ' list ' ),
dns_opts = dict ( type = ' list ' ),
dns_search_domains = dict ( type = ' list ' ),
devices = dict ( type = ' list ' , elements = ' str ' ),
dns_servers = dict ( type = ' list ' , elements = ' str ' ),
dns_opts = dict ( type = ' list ' , elements = ' str ' ),
dns_search_domains = dict ( type = ' list ' , elements = ' str ' ),
domainname = dict ( type = ' str ' ) ,
entrypoint = dict ( type = ' list ' ),
entrypoint = dict ( type = ' list ' , elements = ' str ' ),
env = dict ( type = ' dict ' ) ,
env_file = dict ( type = ' path ' ) ,
etc_hosts = dict ( type = ' dict ' ) ,
exposed_ports = dict ( type = ' list ' , aliases = [ ' exposed ' , ' expose ' ] ),
exposed_ports = dict ( type = ' list ' , aliases = [ ' exposed ' , ' expose ' ] , elements = ' str ' ),
force_kill = dict ( type = ' bool ' , default = False , aliases = [ ' forcekill ' ] ) ,
groups = dict ( type = ' list ' ),
groups = dict ( type = ' list ' , elements = ' str ' ),
hostname = dict ( type = ' str ' ) ,
ignore_image = dict ( type = ' bool ' , default = False ) ,
image = dict ( type = ' str ' ) ,
@ -2333,7 +2346,7 @@ def main():
kernel_memory = dict ( type = ' str ' ) ,
kill_signal = dict ( type = ' str ' ) ,
labels = dict ( type = ' dict ' ) ,
links = dict ( type = ' list ' ),
links = dict ( type = ' list ' , elements = ' str ' ),
log_driver = dict ( type = ' str ' ) ,
log_options = dict ( type = ' dict ' , aliases = [ ' log_opt ' ] ) ,
mac_address = dict ( type = ' str ' ) ,
@ -2343,14 +2356,20 @@ def main():
memory_swappiness = dict ( type = ' int ' ) ,
name = dict ( type = ' str ' , required = True ) ,
network_mode = dict ( type = ' str ' ) ,
networks = dict ( type = ' list ' ) ,
networks = dict ( type = ' list ' , elements = ' dict ' , options = dict (
name = dict ( required = True , type = ' str ' ) ,
ipv4_address = dict ( type = ' str ' ) ,
ipv6_address = dict ( type = ' str ' ) ,
aliases = dict ( type = ' list ' , elements = ' str ' ) ,
links = dict ( type = ' list ' , elements = ' str ' ) ,
) ) ,
oom_killer = dict ( type = ' bool ' ) ,
oom_score_adj = dict ( type = ' int ' ) ,
output_logs = dict ( type = ' bool ' , default = False ) ,
paused = dict ( type = ' bool ' , default = False ) ,
pid_mode = dict ( type = ' str ' ) ,
privileged = dict ( type = ' bool ' , default = False ) ,
published_ports = dict ( type = ' list ' , aliases = [ ' ports ' ] ),
published_ports = dict ( type = ' list ' , aliases = [ ' ports ' ] , elements = ' str ' ),
pull = dict ( type = ' bool ' , default = False ) ,
purge_networks = dict ( type = ' bool ' , default = False ) ,
read_only = dict ( type = ' bool ' , default = False ) ,
@ -2358,22 +2377,22 @@ def main():
restart = dict ( type = ' bool ' , default = False ) ,
restart_policy = dict ( type = ' str ' , choices = [ ' no ' , ' on-failure ' , ' always ' , ' unless-stopped ' ] ) ,
restart_retries = dict ( type = ' int ' , default = None ) ,
security_opts = dict ( type = ' list ' ),
security_opts = dict ( type = ' list ' , elements = ' str ' ),
shm_size = dict ( type = ' str ' ) ,
state = dict ( type = ' str ' , choices = [ ' absent ' , ' present ' , ' started ' , ' stopped ' ] , default = ' started ' ) ,
stop_signal = dict ( type = ' str ' ) ,
stop_timeout = dict ( type = ' int ' ) ,
sysctls = dict ( type = ' dict ' ) ,
tmpfs = dict ( type = ' list ' ),
tmpfs = dict ( type = ' list ' , elements = ' str ' ),
trust_image_content = dict ( type = ' bool ' , default = False ) ,
tty = dict ( type = ' bool ' , default = False ) ,
ulimits = dict ( type = ' list ' ),
ulimits = dict ( type = ' list ' , elements = ' str ' ),
user = dict ( type = ' str ' ) ,
userns_mode = dict ( type = ' str ' ) ,
uts = dict ( type = ' str ' ) ,
volume_driver = dict ( type = ' str ' ) ,
volumes = dict ( type = ' list ' ),
volumes_from = dict ( type = ' list ' ),
volumes = dict ( type = ' list ' , elements = ' str ' ),
volumes_from = dict ( type = ' list ' , elements = ' str ' ),
working_dir = dict ( type = ' str ' ) ,
)