Bootstrap FreeKB - Ansible - Manage Docker networks using the docker_network module
Ansible - Manage Docker networks using the docker_network module

Updated:   |  Ansible articles

If you are not familiar with modules, check out Ansible - Getting Started with Modules.

docker_network is part of the community.docker collection. Typically, the community.docker collection is not included in the default Ansible collections. The ansible-galaxy collection install command can be used to install the community.docker collection.

ansible-galaxy collection install community.docker

 

The docker_network module can be used to create, update and remove a docker network. In this example, the foo-network Docker network will be created.

- name: create Docker network foo-network
  docker_network:
    name: foo-network

 

In this example, the subnet and default gateway are defined.

- name: create Docker network foo-network
  docker_network:
    name: foo-network
    ipam_options:
      subnet: '172.50.0.0/16'
      gateway: '172.50.0.1'

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter e58cd2 in the box below so that we can be sure you are a human.