Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use sysctl to change kernel params in docker file,will the running container affect Host kernel

Tags:

docker

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.

like image 753
zack Avatar asked Nov 09 '22 04:11

zack


1 Answers

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.

like image 103
Mohammed Noureldin Avatar answered Nov 15 '22 06:11

Mohammed Noureldin