Skip to content

Add Sysctl container options #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
amdfxlucas opened this issue Feb 23, 2025 · 1 comment
Closed

Add Sysctl container options #44

amdfxlucas opened this issue Feb 23, 2025 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@amdfxlucas
Copy link

amdfxlucas commented Feb 23, 2025

The sysctl parameters of docker containers(services) can be tuned via the sysctls: section in the docker-compose.yml file.
They're already used to enable IPv4 forwarding (containers acting as routers).
But with the new option system we can seamlessly make SysCtl params regular options which can have different values per node.
This allows i.e. to increase UDP Read/Write buffer sizes on nodes ..

my_node_name:
      ...
    sysctls:
       - net.ipv4.ip_forward=1
       - net.ipv4.udp_rmem_min=${MY_NODE_NAME_UDP_RMEM_MIN}
       - net.ipv4.udp_wmem_min=${MY_NODE_NAME_UDP_WMEM_MIN}

This can even be done on a per Interface level:
Set sysctls for a container's interface (--driver-opt)
sysctl settings that start with net.ipv4. and net.ipv6. can be set per-interface using --driver-opt label com.docker.network.endpoint.sysctls. The name of the interface must be replaced by IFNAME.

To set more than one sysctl for an interface, quote the whole value of the driver-opt field, remembering to escape the quotes for the shell if necessary. For example, if the interface to my-net is given name eth3, the following example sets net.ipv4.conf.eth3.log_martians=1 and net.ipv4.conf.eth3.forwarding=0.

docker network connect --driver-opt="com.docker.network.endpoint.sysctls=net.ipv4.conf.IFNAME.log_martians=1,net.ipv4.conf.IFNAME.forwarding=0" multi-host-network container2
Note

Network drivers may restrict the sysctl settings that can be modified and, to protect the operation of the network, new restrictions may be added in the future.

@amdfxlucas
Copy link
Author

merged upstream seed-labs#293

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

1 participant