After sinking way too much time into trying to get Discourse running on my Mac, I finally got it to work reliably. This post summarizes the steps so you don’t have to spend your precious time trying to debug boot2docker and Discourse.
The setup uses the official Docker Machine installed with Docker Toolbox (tested with version 1.8.2b), which is the successor to boot2docker (I’ll use both names interchangeably). The big issue with running Discourse within the lightweight boot2docker VM is that, by design, any data within the VM is not presisted (excluding the Docker containers themselves) – but Discourse has the
launcher script that manages and provisions the container(s).
After mucking around with VirtualBox shared volumes, only to find them breaking Postgres due to some weird permission issue, I settled on mounting a folder from the VM volume that holds the container data (hat-tip to Lidlanka). To persist that mounting through VM restarts, I wrote (eh, copy-pasted) a boot script, which also installs
bash (needed by
launcher) for you.
Long story short, here is what you need to do (assuming a Mac, Windows should work, too):
- Install Docker Toolbox if you haven’t done so yet.
- Run the Docker Quickstart Terminal.
- SSH into the VM:
docker-machine ssh default
- Create the (persistent) Discourse directory:
- Put this script at
/var/lib/boot2docker/bootlocal.sh(this file will be persisted through reboots), e.g. using
sudo vi /var/lib/boot2docker/bootlocal.sh
- Set the executable bit on the script:
chmod +x /var/lib/boot2docker/bootlocal.sh
- Exit the boot2docker VM:
exit& reboot it:
docker-machine restart default
The VM is now ready to accept your Discourse installation: After reboot is completed, SSH into the VM again. You should now see the Docker folder in
ls -hal /var/discourse. Follow installation instructions for Discourse (start from the
git clone command).
Whenever you want to work with Discourse on your local machine, you need to SSH into the boot2docker VM (
docker-machine ssh default) and execute the
launcher script in
/var/discourse as you would do when running Discourse on a server.