Docker share the kernal with Host.
If I add this in docker file and build a image:
RUN sysctl -w fs.nr_open=2000000
RUN sysctl -w net.ipv4.tcp_tw_recycle=1
Then I run the docker container by this image, will this config affect host OS?
I don't want to affect the host or other containers which doesn't change this configuration.
No, that will not affect the host.
There are some special permissions you can give to your container while running it to be able to affect your host (partially), e.g. privilege, or some other additional specific purpose permissions.
Check this link for more information:
https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities
In your case, I don't know about the first line, but about the second line, as long as you are not using host networking (but any other mode like the default bridge), your host is safe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With