diff --git a/changelogs/fragments/56687-docker_container-networks_cli_compatible.yml b/changelogs/fragments/56687-docker_container-networks_cli_compatible.yml new file mode 100644 index 0000000000..b6420388cd --- /dev/null +++ b/changelogs/fragments/56687-docker_container-networks_cli_compatible.yml @@ -0,0 +1,2 @@ +bugfixes: +- "docker_container - fix network creation when ``networks_cli_compatible`` is enabled." diff --git a/lib/ansible/modules/cloud/docker/docker_container.py b/lib/ansible/modules/cloud/docker/docker_container.py index 8f0e02b170..9881c66af8 100644 --- a/lib/ansible/modules/cloud/docker/docker_container.py +++ b/lib/ansible/modules/cloud/docker/docker_container.py @@ -1282,7 +1282,7 @@ class TaskParameters(DockerBaseClass): if network.get(para): params[para] = network[para] network_config = dict() - network_config[network['name']] = self.client.create_endpoint_config(params) + network_config[network['name']] = self.client.create_endpoint_config(**params) result['networking_config'] = self.client.create_networking_config(network_config) return result diff --git a/test/integration/targets/docker_container/tasks/tests/network.yml b/test/integration/targets/docker_container/tasks/tests/network.yml index 4eefe68433..9da4d6f3fc 100644 --- a/test/integration/targets/docker_container/tasks/tests/network.yml +++ b/test/integration/targets/docker_container/tasks/tests/network.yml @@ -260,6 +260,9 @@ state: started networks: - name: "{{ nname_1 }}" + aliases: + - alias1 + - alias2 - name: "{{ nname_2 }}" networks_cli_compatible: yes register: networks_1