# (Superseded) Try Discourse locally with Docker Machine (ex boot2docker)

**URL:** https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593
**Category:** Self-Hosting
**Tags:** docker, how-to
**Created:** [September 22, 2015, 4:38pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593 "2015-09-22T16:38:39Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![fbender](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fbender/32/116736_2.png) [@fbender](https://meta.discourse.org/u/fbender)
#### Post date: [September 22, 2015, 4:38pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593/1 "2015-09-22T16:38:39Z")

</div>

> ⚠ This topic is no longer maintained. Please see this other topic instead: [Install Discourse for development using Docker](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009)

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](https://docs.docker.com/machine/ "Docker Machine information") installed with [Docker Toolbox](https://www.docker.com/toolbox "Docker Toolbox information") (tested with version 1.8.2b), which is the successor to [boot2docker](http://boot2docker.io/ "boot2docker information") (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](https://docs.google.com/document/d/1i2lkCV9RPpckC8xRRb8yeGhj1Jebyha-5OHpFiiaTYg/pub "Run discourse within boot2docker")). To persist that mounting through VM restarts, I wrote (eh, copy-pasted) a [boot script](https://gist.github.com/fbender/67b99612cf83130e0a2e "Docker Machine boot script to persist Discourse data"), 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):

1. Install [Docker Toolbox](https://www.docker.com/toolbox "Docker Toolbox information") if you haven’t done so yet.
2. Run the Docker Quickstart Terminal.
3. SSH into the VM: `docker-machine ssh default`
4. Create the (persistent) Discourse directory: `mkdir /mnt/sda1/var/discourse`
5. Put [this script](https://gist.github.com/fbender/67b99612cf83130e0a2e "Docker Machine boot script to persist Discourse data") at `/var/lib/boot2docker/bootlocal.sh` (this file will be persisted through reboots), e.g. using `vi`: `sudo vi /var/lib/boot2docker/bootlocal.sh`
6. Set the executable bit on the script: `chmod +x /var/lib/boot2docker/bootlocal.sh`
7. 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 `/var`: `ls -hal /var/discourse`. Follow [installation instructions for Discourse](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md#install-discourse "Discourse installation instructions") (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.

HTH,  
@fbender

---

<div class="post-metadata">

### Author: ![aventurella](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aventurella/32/122051_2.png) [@aventurella](https://meta.discourse.org/u/aventurella)
#### Post date: [December 28, 2015, 6:55pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593/2 "2015-12-28T18:55:24Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![fbender](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fbender/32/116736_2.png) [@fbender](https://meta.discourse.org/u/fbender)
#### Post date: [December 30, 2015, 4:02pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593/3 "2015-12-30T16:02:28Z")

</div>

Unfortunately, the `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) `docker-machine` install.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [December 30, 2015, 9:52pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593/4 "2015-12-30T21:52:33Z")

</div>

Pretty sure we support custom flags for Docker, you can connect to a remote machine if needed.

---

<div class="post-metadata">

### Author: ![fbender](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fbender/32/116736_2.png) [@fbender](https://meta.discourse.org/u/fbender)
#### Post date: [December 31, 2015, 1:57pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593/5 "2015-12-31T13:57:13Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![Tom\_Newsom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tom_newsom/32/115981_2.png) [@Tom\_Newsom](https://meta.discourse.org/u/Tom_Newsom)
#### Post date: [June 17, 2016, 10:05pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593/6 "2016-06-17T22:05:14Z")

</div>

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!

![](https://global.discourse-cdn.com/meta/original/3X/8/5/85e9c33d663bf203eaa655bf3b89e8b7ec132aa1.png)

Someone please tell me the newbie mistake I’ve made here?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [June 17, 2016, 11:18pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593/7 "2016-06-17T23:18:44Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![Tom\_Newsom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tom_newsom/32/115981_2.png) [@Tom\_Newsom](https://meta.discourse.org/u/Tom_Newsom)
#### Post date: [June 18, 2016, 12:35pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593/8 "2016-06-18T12:35:53Z")

</div>

I get the same result with PuTTY and with Docker-Quickstart’s own terminal. Sudo doesn’t help.

 ![](https://global.discourse-cdn.com/meta/original/3X/b/6/b67d11fa72710453a716ba29c045f12ff357091b.png)

Think I’ll give a full-fat VM a go instead

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [June 18, 2016, 1:15pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593/9 "2016-06-18T13:15:32Z")

</div>

> [@Tom\_Newsom](#):
>
> 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,

```plaintext
https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md
Install VMware Player 
Install "vmware-tools"
download Ubunto iso
install docker 
clone discourse 
wget -qO- https://get.docker.com/ | sh
sudo -s
mkdir /var/discourse
git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse
./discourse-setup

```

---

<div class="post-metadata">

### Author: ![Tom\_Newsom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tom_newsom/32/115981_2.png) [@Tom\_Newsom](https://meta.discourse.org/u/Tom_Newsom)
#### Post date: [June 19, 2016, 3:03pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593/10 "2016-06-19T15:03:54Z")

</div>

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:

 ![](https://global.discourse-cdn.com/meta/original/3X/b/6/b644dd88c0cf6f4f76c9dff25ac778937314b340.png)

IIS?!

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

---

<div class="post-metadata">

### Author: ![fbender](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fbender/32/116736_2.png) [@fbender](https://meta.discourse.org/u/fbender)
#### Post date: [June 19, 2016, 3:43pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593/11 "2016-06-19T15:43:26Z")

</div>

> [@Tom\_Newsom](#):
>
> 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!

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).

---

<div class="post-metadata">

### Author: ![Tom\_Newsom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tom_newsom/32/115981_2.png) [@Tom\_Newsom](https://meta.discourse.org/u/Tom_Newsom)
#### Post date: [June 19, 2016, 8:23pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593/12 "2016-06-19T20:23:10Z")

</div>

Fixed it. Bridged connection worked 🙂

---

<div class="post-metadata">

### Author: ![mcwumbly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/32/103861_2.png) [@mcwumbly](https://meta.discourse.org/u/mcwumbly)
#### Post date: [September 26, 2022, 7:14pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593/15 "2022-09-26T19:14:54Z")

</div>



---

<div class="post-metadata">

### Author: ![mcwumbly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/32/103861_2.png) [@mcwumbly](https://meta.discourse.org/u/mcwumbly)
#### Post date: [September 26, 2022, 7:14pm UTC](https://meta.discourse.org/t/superseded-try-discourse-locally-with-docker-machine-ex-boot2docker/33593/16 "2022-09-26T19:14:57Z")

</div>


