Search code examples
dockerdockerfiledocker-networkdocker-build

Change network settings (net.ipv4.ip_default_ttl) in Dockerfile (or, ideally, for any container)


I want to change TTL from 64 to 65 for every docker container (including those, which are started during docker build command).

My current approach is add command

RUN echo 65 >/proc/sys/net/ipv4/ip_default_ttl

to beginning of Dockerfile, but this gives me error

mount: /proc/sys: permission denied


How can I change TTL, so that during docker build TTL 65 is used?

# Dockerfile

# command to change TTL
RUN ???
# this should executes as TTL is 65
RUN curl google.com

Solution

  • Not recommended to change config directly from /proc/sys.

    Try to change iptables instead:

     RUN iptables -t mangle -A POSTROUTING -j TTL —ttl-set 65