[英]specify sysctl values using docker-compose
I am trying to set a few sysctl values. 我试图设置一些sysctl值。
Basically the following 基本上如下
sysctl -w \
net.ipv4.tcp_keepalive_time=300 \
net.ipv4.tcp_keepalive_intvl=60 \
net.ipv4.tcp_keepalive_probes=9
in a docker container. 在码头工人的容器中。
When log into to the container directly and execute the command, I get the following error 直接登录到容器并执行命令时,出现以下错误
sysctl: cannot stat /proc/sys/net/ipv4/tcp_keepalive_time: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/tcp_keepalive_intvl: No such file or directory
sysctl: cannot stat /proc/sys/net/ipv4/tcp_keepalive_probes: No such file or directory
Then I found out the --sysctl option in docker run
in here But I did not find the equivalent option via docker-compose. 然后我发现了docker中的--sysctl选项在这里 docker run
但是我没有通过docker-compose找到相同的选项。 I have few services that start by default so using docker run instead of docker-compose is not an option for me. 我有一些默认启动的服务,所以使用docker run而不是docker-compose对我来说不是一个选项。
Anyone knows of a way to supply --sysctl options to the container via compose? 任何人都知道通过compose为容器提供--sysctl选项的方法吗?
This option is now available in docker-compose 1.10.0-rc1, you'll need to upgrade to that version ( pip install docker-compose==1.10.0-rc1
) and also update your docker-compose.yml
file to version 2.1 per docs 此选项现在在docker-compose 1.10.0-rc1中可用,您需要升级到该版本( pip install docker-compose==1.10.0-rc1
)并将docker-compose.yml
文件更新为版本2.1每份文件
Example docker-compose.yml: 示例docker-compose.yml:
version: '2.1'
services:
app:
build: .
sysctls:
- net.ipv6.conf.all.disable_ipv6=1
docker-compose lacks many of the CLI options. docker-compose缺少许多CLI选项。 In general, you have to head over to the github issues for compose and search there. 一般来说,你必须转到github问题进行撰写和搜索。 In the case of sysctl
, it's in the process of being added. 在sysctl
的情况下,它正在被添加。 Someone has made a branch with the addition . 有人添加了一个分支 。 You could start with that until it gets added to the master branch. 你可以从那开始,直到它被添加到主分支。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.