Skip to content

Instantly share code, notes, and snippets.

@dweomer
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dweomer/67306d31da5b461f09bc to your computer and use it in GitHub Desktop.
Save dweomer/67306d31da5b461f09bc to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ "$1" = "" ]; then
echo "Usage: $0 <host> [<fallocate length>]"
exit 1
fi
DOCKER_MACHINE_HOST_NAME=$1
DOCKER_MACHINE_SWAP_SIZE=${DOCKER_MACHINE_SWAP_SIZE:-2G}
exec docker-machine ssh $1 -- sh -x << EOF
if [ ! -f /var/swapfile ]; then
fallocate -l ${DOCKER_MACHINE_SWAP_SIZE} /var/swapfile
mkswap /var/swapfile
chmod -v 600 /var/swapfile
echo "/var/swapfile none swap sw 0 0" >> /etc/fstab
fi
sysctl vm.swappiness=10 > /etc/sysctl.d/11-vm-swappiness.conf
sysctl vm.vfs_cache_pressure=50 > /etc/sysctl.d/11-vm-vfs-cache-pressure.conf
swapon -a && swapon -s
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment