Last active
February 26, 2018 10:20
-
-
Save iaon/9117bedc6a146b784de5d2feceb3a11a to your computer and use it in GitHub Desktop.
docker-sysctl.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# from https://blog.codeship.com/running-1000-containers-in-docker-swarm/ | |
SYSCTL=' | |
net.ipv4.ip_local_port_range="1024 65000" | |
net.core.somaxconn=4096 | |
net.netfilter.nf_conntrack_max=262144 | |
net.netfilter.nf_conntrack_tcp_timeout_established=86400 | |
' | |
date | |
containers=$(docker ps --format "{{.Names}}:{{.ID}}") | |
for c in $containers | |
do | |
echo $c | |
CID=$(echo $c | awk -F ":" '{print $2}') | |
echo "${SYSCTL}" | xargs -n 1 nsenter -t $(docker inspect -f '{{.State.Pid}}' $CID) -n sysctl -w | |
echo ---------------------- | |
done | |
echo ================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment