# Install Discourse for development using Docker

**URL:** https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009
**Category:** Developer Guides
**Tags:** docker, dev-install, how-to
**Created:** [November 16, 2018, 9:40am UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009 "2018-11-16T09:40:04Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [March 1, 2020, 1:34pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/104 "2020-03-01T13:34:18Z")

</div>

From my Ubuntu VM I was able to ping [rubygems.org](http://rubygems.org). I don’t know if there’s a way to check if the docker container can. I think I only pinged the http version, not https, though. Mentioning in case the problem is related to that. (One of the pages I saw when googling suggested changing https to http, but it’s not like I can do that since the defined behavior is somewhere in the docker container.)

---

<div class="post-metadata">

### Author: ![Jeremias\_Volker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeremias_volker/32/162032_2.png) [@Jeremias\_Volker](https://meta.discourse.org/u/Jeremias_Volker)
#### Post date: [March 13, 2020, 12:38am UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/105 "2020-03-13T00:38:26Z")

</div>

I’ve tried the **MacOS** options.

First using Option 2, Homebrew. I ran into issues though as not all dependencies were installed using the command of this guide. [https://medium.com/@yutafujii\_59175/a-complete-one-by-one-guide-to-install-docker-on-your-mac-os-using-homebrew-e818eb4cfc3](https://medium.com/@yutafujii_59175/a-complete-one-by-one-guide-to-install-docker-on-your-mac-os-using-homebrew-e818eb4cfc3) helped me getting a bit further.

I’m now stuck at **Step 2** `d/boot_dev --init`:

```
Migrating database...

rake aborted!

PG::ConnectionBad: could not connect to server: No such file or directory

Is the server running locally and accepting

connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

/src/lib/site_settings/db_provider.rb:61:in `table_exists?'

/src/lib/site_settings/db_provider.rb:16:in `all'

/src/lib/site_settings/defaults_provider.rb:29:in `db_all'

/src/lib/site_setting_extension.rb:277:in `block in refresh!'

/src/lib/site_setting_extension.rb:274:in `synchronize'

/src/lib/site_setting_extension.rb:274:in `refresh!'

/src/lib/site_setting_extension.rb:495:in `block in setup_methods'

/src/config/initializers/004-message_bus.rb:120:in `<main>'

/src/config/environment.rb:7:in `<main>'

/usr/local/bin/bundle:23:in `load'

/usr/local/bin/bundle:23:in `<main>'

Tasks: TOP => db:migrate => db:load_config => environment

(See full trace by running task with --trace)

```

I’ve then downloaded the `.dmg` file but as I’m new to Docker, I don’t understand what to do from there. It would be great to have a little more detailed description of the macOS option.

Thanks.

---

<div class="post-metadata">

### Author: ![mentalstring](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mentalstring/32/168934_2.png) [@mentalstring](https://meta.discourse.org/u/mentalstring)
#### Post date: [March 13, 2020, 4:42pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/106 "2020-03-13T16:42:10Z")

</div>

On MacOS, once you install Docker from the `.dmg`, just make sure it’s running — there should be an icon on the MacOS toolbar that you can use to check its status. Then literally follow the steps on the first post (clone, etc). Post here if you hit a problem going that route.

Mind, if you have installed docker with Homebrew before, it may be a good idea to uninstall that docker first or at least making sure that one is not running. I never installed docker with homebrew, so can’t advise there.

---

<div class="post-metadata">

### Author: ![Jeremias\_Volker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jeremias_volker/32/162032_2.png) [@Jeremias\_Volker](https://meta.discourse.org/u/Jeremias_Volker)
#### Post date: [March 13, 2020, 6:25pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/107 "2020-03-13T18:25:53Z")

</div>

Thanks.

I’ve used the icon and opened the Docker dashboard. I didn’t find any containers running there on the command line I could see multiple containers running though. I was wondering if I had to sign in to use Docker dashboard? Or maybe this behaviour occurs since there are multiple versions of Docker installed Homebrew and Desktop (.dmg)?

In the meantime I’ve managed to setup Discourse on DigitalOcean which works without problems and is okay for my purposes.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [March 13, 2020, 6:43pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/108 "2020-03-13T18:43:23Z")

</div>

The DMG installs docker, not discourse. It won’t add any containers initially.

From there you can follow the docker guide.

---

<div class="post-metadata">

### Author: ![pipkin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pipkin/32/134643_2.png) [@pipkin](https://meta.discourse.org/u/pipkin)
#### Post date: [March 20, 2020, 11:15pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/109 "2020-03-20T23:15:41Z")

</div>

> [@rishabh](#):
>
> d/boot\_dev --init

When running the above command (on a Mac) I get this error:

```plaintext
An error occurred while installing cppjieba_rb (0.3.3), and Bundler cannot continue.

Make sure that `gem install cppjieba_rb -v '0.3.3' --source 'https://rubygems.org/'` succeeds

before bundling.

```

Do you have any suggestions? I don’t understand exactly what the problem is. The separate gem install doesn’t work either (even with sudo).

Also, why do gems have to be installed when I’m running a docker image? That should have been fully pre-installed already, right?

> **UPDATE** : FIXED
> 
> I cloned to `~/repos/discourse` but should have been to `~/discourse`. Works like a charm now.

---

<div class="post-metadata">

### Author: ![pipkin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pipkin/32/134643_2.png) [@pipkin](https://meta.discourse.org/u/pipkin)
#### Post date: [March 22, 2020, 3:58pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/110 "2020-03-22T15:58:46Z")

</div>

If you get this error when running `d/unicorn`:

```plaintext
Could not find aws-partitions-1.284.0 in any of the sources
Run `bundle install` to install missing gems.

```

you can fix this by running:

```plaintext
docker exec -it -u discourse:discourse discourse_dev /bin/bash -c "cd /src && USER=discourse RUBY_GLOBAL_METHOD_CACHE_SIZE=131072 LD_PRELOAD=/usr/lib/libjemalloc.so RAILS_ENV=${RAILS_ENV:=development} bundle install"

```

after which `d/boot_dev` will run succesfully.

---

<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: [March 24, 2020, 12:12am UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/111 "2020-03-24T00:12:45Z")

</div>

> [@pipkin](#):
>
> you can fix this by running: ..

Simpler

```plaintext
d/boot_dev
d/bundle install

```

We have helpers for all the usual tasks.

---

<div class="post-metadata">

### Author: ![Sam\_Rose](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam_rose/32/120403_2.png) [@Sam\_Rose](https://meta.discourse.org/u/Sam_Rose)
#### Post date: [April 3, 2020, 3:24pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/112 "2020-04-03T15:24:34Z")

</div>

In the OP it reads

> The Docker development flow supports symlinks under the `plugins/` directory

What do we symlink the plugins directory to in this context? Thanks!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 3, 2020, 3:27pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/113 "2020-04-03T15:27:40Z")

</div>

```plaintext
cd plugins
ln -s /full/path/to/your/plugin .
ln -s ~/src/my-great-plugin # for example

```

---

<div class="post-metadata">

### Author: ![Sam\_Rose](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam_rose/32/120403_2.png) [@Sam\_Rose](https://meta.discourse.org/u/Sam_Rose)
#### Post date: [April 3, 2020, 3:29pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/114 "2020-04-03T15:29:24Z")

</div>

Ah thanks just meaning to symlink to the plugins directory in this context.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [April 4, 2020, 3:42pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/115 "2020-04-04T15:42:51Z")

</div>

Generally you don’t symlink an entire directory for this workflow as you would normally want granular control over which plugins were in scope during a run.

---

<div class="post-metadata">

### Author: ![Kurisu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kurisu/32/275373_2.png) [@Kurisu](https://meta.discourse.org/u/Kurisu)
#### Post date: [August 11, 2020, 4:17am UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/116 "2020-08-11T04:17:16Z")

</div>

Hi, I’m using this guide and it works fine but my concern is whenever I run `d/boot_dev` it start downloading various things. How to just download once the necessary files and keep them for next boot? My OS is ubuntu 20.04

---

<div class="post-metadata">

### Author: ![Terrapop](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@Terrapop](https://meta.discourse.org/u/Terrapop)
#### Post date: [August 24, 2020, 5:31pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/117 "2020-08-24T17:31:04Z")

</div>

Tried to install on a fresh Mint 20 system. Docker is available:

```
terrapop@terrapop:/var$ docker version
Client: Docker Engine - Community
 Version: 19.03.12

terrapop@terrapop:/var/discourse$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset>
     Active: active (running) since Mon 2020-08-24 19:03:48 CEST; 31min ago

```

Then cloned Discourse:

sudo git clone [GitHub - discourse/discourse\_docker: A Docker image for Discourse · GitHub](https://github.com/discourse/discourse_docker.git) /var/discourse  
cd /var/discourse

However, d/boot\_dev --init leads to:

d/boot\_dev --init

`bash: d/boot_dev: No such file or directory`

Anybody?

---

<div class="post-metadata">

### Author: ![Terrapop](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@Terrapop](https://meta.discourse.org/u/Terrapop)
#### Post date: [August 24, 2020, 9:27pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/119 "2020-08-24T21:27:11Z")

</div>

Update: I have now added our sendgrid api keys to the app.yml and bootstrapped the app via ./launcher and now it runs on localhost. Could it be that those d/commands in the OP are all outdated? Still, don’t get it. The app is now running in docker on my Ubuntu (Mint) computer on localhost like it does on staging at Digital Ocean. We want to develop on localhost having the app running via Docker with symlinks for plugins, but I’m not sure if it’s now ready like it should as I can’t execute those d/ commands in any way. Could someone please chip in? Thanks.

Update: My fault. I took the git link for production:

git clone [GitHub - discourse/discourse\_docker: A Docker image for Discourse · GitHub](https://github.com/discourse/discourse_docker.git) /var/discourse

Instead of:

git clone [GitHub - discourse/discourse: A platform for community discussion. Free, open, simple. · GitHub](https://github.com/discourse/discourse.git)

🤠

However…

Now running into new problems. I can only clone into /var as superuser/root on Ubuntu Mint 20 (UID 0). So when I clone and run d/boot\_dev --init everything downloads and start fine, but when then at a later stage the script throws a Permission Error as it expects to run something with UID 1000, which is the first user created on Mint, thus my personal account (terrapop), and not root. How to get around this problem?

Solution: Simpler than I thought. Just create a new www directory in var. chown and chmod the www directory to your first user on Mint and proceed as in OP’s posts. Works now. Happy.

---

<div class="post-metadata">

### Author: ![a\_lee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/a_lee/32/134326_2.png) [@a\_lee](https://meta.discourse.org/u/a_lee)
#### Post date: [August 26, 2020, 11:19pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/120 "2020-08-26T23:19:52Z")

</div>

For some reason symlinks to my plugin source directories were not working and I needed to manually move / copy the plugin source directories into the `plugins` directory to get them to appear in `/admin/plugins` after restarting the Docker container.

Perhaps there was a change in how Docker supports symlinks? I’m running docker-ce 19.03.12 on Ubuntu.

---

<div class="post-metadata">

### Author: ![mentalstring](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mentalstring/32/168934_2.png) [@mentalstring](https://meta.discourse.org/u/mentalstring)
#### Post date: [August 27, 2020, 7:10am UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/121 "2020-08-27T07:10:12Z")

</div>

I have experienced this too recently with Docker Desktop for Mac.

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [September 21, 2020, 5:17pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/123 "2020-09-21T17:17:09Z")

</div>

I did the same steps in a $5 DO droplet. Everything went fine. Now how do I expose my site so that I can access it ?

~~P.S. It works with ngrok. Doesn’t yet work with nginx reverse proxy to 9292~~

> [@rishabh](#):
>
> If you wish to globally expose the ports from the container to the network (default off) use:
> 
> ```plaintext
> d/boot_dev -p
> 
> ```

Thanks to this. You can do this on the server and avoid configuring nginx reverse proxy. Enjoying d/o docker+vscode remote setup 🙂

use `d/unicorn -D` to run unicorn as daemon so the shell is still usable after starting the server.

Also you need atleast $10 d/o droplet.

---

<div class="post-metadata">

### Author: ![aleber](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aleber/32/151754_2.png) [@aleber](https://meta.discourse.org/u/aleber)
#### Post date: [October 14, 2020, 8:18am UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/124 "2020-10-14T08:18:10Z")

</div>

I’m on a Mac with `zsh` (on iTerm2) and if I try to use symbolic link for plugins development I get stuck with this errors:

```plaintext
readlink: illegal option -- f
usage: readlink [-n] [file ...]

```

This because the Mac implementation of the `readlink` command is slightly different from the GNU one.

The easiest way to solve this is by doing this:

```plaintext
# brew install coreutils
# ln -s "$(which greadlink)" "$(dirname "$(which greadlink)")/readlink"

```

This will give you the possibility to use a compatible readlink version.

Please remember you need to have `dirname "$(which greadlink)"` value on your `PATH` in a position preceding the `/usr/bin` (where usually the original `readlink` is). On my case `PATH` is something like `/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:...` and the symbolik link to greadlink is in `/usr/local/bin`.

Reference: [Fixing "readlink: illegal option -- f" error on a Mac](http://biercoff.com/fixing-readlink-illegal-option-f-error-on-a-mac/)

---

<div class="post-metadata">

### Author: ![aleber](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aleber/32/151754_2.png) [@aleber](https://meta.discourse.org/u/aleber)
#### Post date: [October 16, 2020, 9:38pm UTC](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009/127 "2020-10-16T21:38:35Z")

</div>

To run a single plugin test suite, you can do in this way:

```plaintext
# d/rake "plugin:spec[PLUGIN_NAME]"

```

[Previous page](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009.md?page=1)

[Next page](https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009.md?page=3)
