Skip to content

Instantly share code, notes, and snippets.

@iaon
Last active February 26, 2018 10:20
Show Gist options
  • Save iaon/9117bedc6a146b784de5d2feceb3a11a to your computer and use it in GitHub Desktop.
Save iaon/9117bedc6a146b784de5d2feceb3a11a to your computer and use it in GitHub Desktop.
docker-sysctl.sh
#!/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