Skip to content

Enable IP forwarding on the server

Problem

It seems that Docker containers need IP forwarding for external communication. It also seems that IP forwarding is enabled by the Docker daemon at startup (--ip-forward argument). However, when we restart the networking system service, something bad happens to IP forwarding, and containers lose connectivity with the external world.

Solution

Set net.ipv4.ip_forward to 1 on the server running Docker.

Proposition

Add a nice task to the install_base action, e.g.

- name: "enable IP forwarding"
  become: yes
  sysctl:
    name: "net.ipv4.ip_forward"
    value: 1
    state: present
    reload: yes
    sysctl_set: yes

If we're paranoid, we may also add some Ansible variable for controlling if we want this or not. (If you think we need such an option, please provide an example).

Edited by Tomasz Ziółkowski
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information