Long time, no post. That’s what we call holidays. Anyways, here’s how to increase the size of swap available in Docker.
When you try to set up an OracleDB inside a docker container, you’ll probably need this.
This works only with the native virtualization version of Docker for Mac. If you still use boot2docker, you need to follow the guide in this issue.
This guide was updated in February 2018 because Docker has changed the underlying VM. (more info)
Nowadays changing the swap size is possible in the Docker Desktop settings.
- Open any terminal, make sure that screen is installed (use Homebrew)
- Connect to the Docker VM:
- You might need to press enter or login to show the prompt. The username is root and the password is empty.
- Create a new swapfile:
dd if=/dev/zero of=/var/lib/swapfile count=2000000 bs=1024
- Change the permissions and run mkswap:
chmod go= /var/lib/swapfile && mkswap /var/lib/swapfile
- Activate the swap:
swapon -v /var/lib/swapfile
dto detach the screen session.
Note that you’ll lose the swap, when the machine is recreated or you restart Docker.
In this case you’ll just need to repeat steps two and six to eight, because the swapfile is still present (unless you completely recreated the Docker machine).