This topic is no longer maintained. Please see this other topic instead: Install Discourse for development using Docker
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.
Thanks for this!
I will admit though, needing to SSH into the docker-machine VM sort of defeats the purpose of docker-machine a lil bit =) I guess we could just make a new docker-machine vm for discourse specifically and destroy it when done.
launcher script expects the host of the Docker client to also be the host of the Docker container. Until that is fixed, you need to enter the VM in some way (SSH here) and execute the
launcher script there.
Having a special docker-machine VM would be an idea, but IMHO it’s (on the admin side) only minimally different to running Discourse directly in a VM (like the Dev setup with the Vagrant file in the repository). It would also require packaging up everything and downloading it alongside any other (potential)
Pretty sure we support custom flags for Docker, you can connect to a remote machine if needed.
Yeah, you can set the env variables for the
docker client, too, but I’m mostly talking about the infra stuff included in
launcher, e.g. version and size checks (they would fail on my machine since the VMs are on a separate disk and my main drive is pretty full) and especially host volume and
/var/discourse/* stuff. My intent was to have a vanilla Discourse container install with no (or minimal) modifications (which in turn means some modifications to the standard Docker Machine / boot2docker install).
I’m just trying to set up a local copy of discourse on my Windows machine so I can test plugins/css etc without messing up my main site, and this seems the most self-contained way to do it (and will result in the closest operating process to sshing into my live site).
I’ve got as far as doing the
git clone but ./discourse-setup just gives me
sh: ./discourse-setup: not found. What gives? It’s right there! I can see it!
Someone please tell me the newbie mistake I’ve made here?
What’s the “sh:” ?
Seems it would give a “need sudo or root” message if it was a permission issue, but maybe not.
Did you use PuTTY to set-up your SSH ?
I get the same result with PuTTY and with Docker-Quickstart’s own terminal. Sudo doesn’t help.
Think I’ll give a full-fat VM a go instead
Yes, that’s odd. I could see getting any error other than not finding what’s obviously there.
I did this after my GitHub - VirtualBox - Vagrant set-up was a no go,
Install VMware Player
download Ubunto iso
wget -qO- https://get.docker.com/ | sh
git clone https://github.com/discourse/discourse_docker.git /var/discourse
I’ve just done exactly that, without incident.
I switched the VM’s network to Host Only so I could connect to it from the host machine. I can ping it ok, but I get this if I try and browse to it:
Discourse is definitley running (I can CURL it from inside the VM and get the home page back). What am I missing in terms of getting http in and out of the VM?
EDIT: PuTTY won’t connect to 192.168.56.1 either
Looks either like a permission error or the shell was not installed (type
bash and see what happens). Did you restart your Docker machine after updating the
bootlocal.sh file? Was
bash installed successfully?
Note that I did not check if the guide still works for the current versions of both the
discourse_docker repository and Docker Machine (they changed the way it works).
Fixed it. Bridged connection worked