我正在构建一个容器来调整负载均衡器的内核设置。我更喜欢使用单个特权容器将这些更改部署到映像中的主机。例如:
docker run --rm --privileged ubuntu:latest sysctl -w net.core.somaxconn=65535
Run Code Online (Sandbox Code Playgroud)
在测试中,更改生效但仅适用于该容器。我的印象是,使用完全特权的容器更改 /proc 实际上会更改底层操作系统。
$docker run --rm --privileged ubuntu:latest \
sysctl -w net.core.somaxconn=65535
net.core.somaxconn = 65535
$ docker run --rm --privileged ubuntu:latest \
/bin/bash -c "sysctl -a | grep somaxconn"
net.core.somaxconn = 128
Run Code Online (Sandbox Code Playgroud)
这是特权容器应该如何工作吗?
我只是在做一些愚蠢的事情吗?
做出持久改变的最佳方法是什么?
版本信息:
Client version: 1.4.1
Client API version: 1.16
Go version (client): go1.3.3
Git commit (client): 5bc2ff8
OS/Arch (client): linux/amd64
Server version: 1.4.1
Server API version: 1.16
Go version (server): go1.3.3
Git commit (server): 5bc2ff8
Run Code Online (Sandbox Code Playgroud)
挂载 /proc …