# Docker setup for development

**URL:** https://meta.discourse.org/t/docker-setup-for-development/72354
**Category:** Development
**Created:** [October 18, 2017, 5:02pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354 "2017-10-18T17:02:25Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![drew0101](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@drew0101](https://meta.discourse.org/u/drew0101)
#### Post date: [October 18, 2017, 5:02pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/1 "2017-10-18T17:02:25Z")

</div>

Hello, I am working on setting up Discourse locally and am very confused. I have read that the “The only officially supported installs of Discourse are Docker based.” ([discourse/docs/INSTALL.md at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/docs/INSTALL.md)) So I would like to set up with docker. However the guides only talk about setting up discourse directly on a DigitalOcean server. Thats great but doesn’t help me as I want to develop in discourse locally before ever deploying to a server. I am also confused because the main discourse GitHub only has links to a Vagrant install. So what is the official supported version, Vagrant or Docker? Can someone please point me in the direction to set up a discourse docker environment locally? Any help would be greatly appreciated. Thank you!

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [October 18, 2017, 5:14pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/2 "2017-10-18T17:14:23Z")

</div>

The only supported install version for _production_ is Docker. For development (as you’ve noticed) you have far more options. Vagrant is one, if you want to do development locally in docker, see [https://github.com/discourse/discourse/tree/master/bin/docker](https://github.com/discourse/discourse/tree/master/bin/docker).

---

<div class="post-metadata">

### Author: ![drew0101](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@drew0101](https://meta.discourse.org/u/drew0101)
#### Post date: [October 18, 2017, 5:22pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/3 "2017-10-18T17:22:02Z")

</div>

Oh that makes sense. Thank you! I also dont have a ./discourse-setup script. So I am confused as to how to set up emails etc

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [October 18, 2017, 5:26pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/4 "2017-10-18T17:26:47Z")

</div>

The Discourse Setup script is intended for production. If you wish to use Docker for development, follow the guide I linked above.

---

<div class="post-metadata">

### Author: ![drew0101](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@drew0101](https://meta.discourse.org/u/drew0101)
#### Post date: [October 18, 2017, 6:27pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/5 "2017-10-18T18:27:48Z")

</div>

I am having some issues using docker in development and ran into this article saying that Docker is not for devlopment. These are a couple years old, has this changed? [https://meta.discourse.org/t/development-environment-vagrant-or-docker/12170/5](https://meta.discourse.org/t/development-environment-vagrant-or-docker/12170/5)

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [October 18, 2017, 6:28pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/6 "2017-10-18T18:28:55Z")

</div>

I do believe things have changed. But I’m not an engineer. @sam can confirm.

---

<div class="post-metadata">

### Author: ![drew0101](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@drew0101](https://meta.discourse.org/u/drew0101)
#### Post date: [October 18, 2017, 6:32pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/7 "2017-10-18T18:32:38Z")

</div>

By any chance is there a guide to using docker and discourse in development? I am new to docker, so maybe I am missing something, but it looks like I need to have ‘./bin/docker/’ before all my commands. Why doesn’t docker-run work?

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [October 18, 2017, 6:35pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/8 "2017-10-18T18:35:10Z")

</div>

The guide is linked to in my second post: [https://github.com/discourse/discourse/tree/master/bin/docker](https://github.com/discourse/discourse/tree/master/bin/docker).

You need to complete the following:

1. Install git.
2. Clone Discourse locally.
3. Install docker.
4. Run the two commands in the guide.

---

<div class="post-metadata">

### Author: ![drew0101](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@drew0101](https://meta.discourse.org/u/drew0101)
#### Post date: [October 18, 2017, 6:38pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/9 "2017-10-18T18:38:18Z")

</div>

Thanks for answering so fast Joshua. Let me clarify. I have followed the commands in that link and am running the discourse server locally through docker. Now I want to run commands such as ‘rake db:migrate’ but how do I run those commands within the docker container? I am also confused as I dont see a Dockerfile or docker compose. My understanding is that when using docker I should be able to run ‘docker-run rake db:migrate’ to migrate the db within the docker container.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [October 18, 2017, 6:50pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/11 "2017-10-18T18:50:47Z")

</div>

Take a look at all the scripts inside [bin/docker](https://github.com/discourse/discourse/tree/master/bin/docker). They are very helpful and one of them is `migrate`.

So, calling `./bin/docker/migrate` will migrate your development and test database.  
Of course you can also use `./bin/docker rake` if you want to execute other rake tasks.

You can also follow the instructions of the [Install Discourse on Ubuntu or Debian for Development](https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-ubuntu-for-development/14727) if you don’t want to use the Docker based environment.

---

<div class="post-metadata">

### Author: ![xrav3nz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xrav3nz/32/76894_2.png) [@xrav3nz](https://meta.discourse.org/u/xrav3nz)
#### Post date: [October 18, 2017, 6:54pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/12 "2017-10-18T18:54:08Z")

</div>

If you take a look at the scripts in [discourse/bin/docker at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/bin/docker)

`boot_dev` creates and runs a container in detached mode, and `rails`/`rake`/etc utilizes `docker exec` to run the respective commands in the existing container, which are intended to make running those commands easier.

As for the `Dockerfile` question, it is answered in the README linked before: [discourse/bin/docker/README.md at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/bin/docker/README.md#where-is-the-container-imagedockerfile-defined)

* * *

There is a folder `d` at the project root symlinked to `bin/docker`, thus you can actually do `d/boot_dev`, `d/rails s`, etc.

---

<div class="post-metadata">

### Author: ![drew0101](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@drew0101](https://meta.discourse.org/u/drew0101)
#### Post date: [October 18, 2017, 7:07pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/13 "2017-10-18T19:07:03Z")

</div>

Thanks everyone! Its all starting to come together. @xrav3nz I am not having any success with docker exec as it says ‘Error: No such container \<rails, rake, etc\>’. However the ‘d/’ works as I expected. Is there any reason to use docker exec over d/ ?

---

<div class="post-metadata">

### Author: ![xrav3nz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xrav3nz/32/76894_2.png) [@xrav3nz](https://meta.discourse.org/u/xrav3nz)
#### Post date: [October 18, 2017, 7:28pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/14 "2017-10-18T19:28:06Z")

</div>

Have you ran `d/boot_dev --init` first? If so, then `d/rails`, `d/rake`, etc should work fine.

> [@drew0101](#):
>
> Is there any reason to use docker exec over d/ ?

Of course you can manage/interact with the container directly yourself, but I’d say the helper scripts are … helpful? I hack on Discourse locally with the Docker setup, and the helper scripts are all I need so far.

* * *

EDIT: just realized your question was regarding using `docker exec` specifically, in that case, I recommand checking out [the official reference](https://docs.docker.com/engine/reference/commandline/exec/) (or the helper scripts themselves) and then you will see the necessary syntax to interact with an existing container.

---

<div class="post-metadata">

### Author: ![drew0101](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@drew0101](https://meta.discourse.org/u/drew0101)
#### Post date: [October 18, 2017, 7:40pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/15 "2017-10-18T19:40:59Z")

</div>

After reading the docs I realized I wasn’t specifying a container. So if you were to use docker exec to migrate your database, would you just run ‘docker exec rake db:migrate’ or ‘docker exec discourse\_dev rake db:migrate’? The second option appears correct from the docker docs, but it says that there was no Rakefile found. Running ‘docker ps’ shows that discourse\_dev is the only container I have running. So now I am wondering if ‘d/rake db:migrate’ is running in the discourse\_dev container or something else?

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [October 18, 2017, 9:16pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/16 "2017-10-18T21:16:35Z")

</div>

The scripts under `d` are helpers that automatically execute commands inside the container - I would suggest looking at them if you’re curious:

```bash
± |master ✓| → cat d/rake
#!/bin/bash

PARAMS="$@"
CMD="cd /src && RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 LD_PRELOAD=/usr/lib/libjemalloc.so RAILS_ENV=${RAILS_ENV:=development} bundle exec rake $PARAMS"
docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "$CMD"

```

---

<div class="post-metadata">

### Author: ![ChrisBeach](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chrisbeach/32/214628_2.png) [@ChrisBeach](https://meta.discourse.org/u/ChrisBeach)
#### Post date: [October 18, 2017, 9:32pm UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/17 "2017-10-18T21:32:12Z")

</div>

I think it would be wise to remove the Vagrant option and focus on Docker development, updating and clearing out any redundant documentation.

Fledgling developers would benefit from a development portal (a wiki topic linked from the top nav) that, in turn, linked to the _current_ state of the art guidance, and to plugins that are well maintained and serve as canonical examples for developers.

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [October 19, 2017, 11:31am UTC](https://meta.discourse.org/t/docker-setup-for-development/72354/18 "2017-10-19T11:31:18Z")

</div>

Also see this:

> [@Running Discourse on Docker for Mac](https://meta.discourse.org/t/running-discourse-on-docker-for-mac/49682/18):
>
> This is looking like the most promising solution for Mac/windows dev Going to test it out [http://docker-sync.io](http://docker-sync.io)
