Skip to content

Instantly share code, notes, and snippets.

@fud
Created September 3, 2016 08:06
Show Gist options
  • Save fud/9d925facca6b94c47b5a8d969cb47122 to your computer and use it in GitHub Desktop.
Save fud/9d925facca6b94c47b5a8d969cb47122 to your computer and use it in GitHub Desktop.
More swap space for a docker machine.
for i in $(docker-machine ls | awk '{print $1}'); do
docker-machine ssh $i -- ls /swapfile || docker-machine ssh $i "fallocate -l 512M /swapfile && chmod 400 /swapfile && mkswap /swapfile" &&
docker-machine ssh $i "swapon /swapfile && echo '/swapfile none swap defaults 0 0' >> /etc/fstab" &>/dev/null;
done
@arvindkumarc
Copy link

arvindkumarc commented Oct 17, 2017

boot2docker complains about fallocate not being present, any idea how to overcome this?

@moritzschaefer
Copy link

@arvindkumarc and googlers you can use dd instead of fallocate:

# dd if=/dev/zero of=/swapfile bs=1M count=512

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment