Install Discourse for development using Docker

How do we use the Discourse Theme CLI (console app to help you build themes) here?

We’ve successfully installed the gem: d/exec sudo gem install discourse_theme … now the challenge is to symlink to local theme …

@Simon_Manning note use of sudo to get around permissions (thanks for reminder @fzngagan)

I’m trying to test a plugin using the docker setup. Randomly the app stops loading and I’m just presented with a blank page until I delete the data folder and rebuild everything. Any tips on how to debug the issue?

Have there been any findings on that one? Still seems to be an issue.

My “dirty” workaround was to replace the username from postgres to discourse on the following block of code:

# lib/backup_restore.rb:122
      config["backup_host"] || config["host"],
      config["backup_port"] || config["port"],
      config["username"] || username || ENV["USER"] || "postgres",
      config["password"] || password,

I switched from my local Mac to a Ubuntu VM hoping this would make it easier to get this running but unfortunately so far it’s not.

Already fighting some weird permission problems in the early stages. d/bundle install reports it needs sudo rights to install some, d/rails s also comes back with permission problems

Traceback (most recent call last):
        8: from /src/bin/unicorn:70:in `<main>'
        7: from /src/bin/unicorn:38:in `ensure_cache_clean!'
        6: from /usr/local/lib/ruby/2.7.0/fileutils.rb:211:in `mkdir_p'
        5: from /usr/local/lib/ruby/2.7.0/fileutils.rb:211:in `each'
        4: from /usr/local/lib/ruby/2.7.0/fileutils.rb:226:in `block in mkdir_p'
        3: from /usr/local/lib/ruby/2.7.0/fileutils.rb:226:in `reverse_each'
        2: from /usr/local/lib/ruby/2.7.0/fileutils.rb:228:in `block (2 levels) in mkdir_p'
        1: from /usr/local/lib/ruby/2.7.0/fileutils.rb:250:in `fu_mkdir'
/usr/local/lib/ruby/2.7.0/fileutils.rb:250:in `mkdir': Permission denied @ dir_s_mkdir - /src/tmp (Errno::EACCES)

Any idea what’s going wrong? This machine previously ran a production discourse without issues. I just stopped and removed those containers and cloned the dev git repo into a different directory. Running it all through tmux to handle the differen shell instances.

I’m not on M1 yet, but I’m expecting to switch very soon, and I really prefer the convenience of the Docker setup.

That PR link links to where they say:

the only solution is to switch to arm64-capable multi-arch images. These will also be a lot faster and generally more reliable. I recommend investigating which base images you’re using and to switch to multi-arch ones where possible. You can see which architectures are supported by each image on Docker Hub: […]

To build a multi-arch image yourself, I recommend docker buildx , check out this blog post:

Is the Discourse team open to supporting a multi-arch image? It looks like the Discourse base image is based on debian:buster-slim, which is multi-arch, so it seems like it shouldn’t be outrageously difficult to make the Discourse base image be multi-arch, but that might put y’all in the position of having to support ARM (in production!). Somebody (the Discourse team?) would need to run the Discourse tests on both x86_64 and ARM, fix issues when they fail, etc.

Would a PR even be welcome here?

(IMO, it seems like ARM is the architecture of the future, even on cloud-hosted environments.)


I’m trying to set this up on WSL2.

I’ve got down to starting ember_cli but Chrome give me the following error:

There are no errors visible in either terminal or the development log. Any suggestions welcome, please?

1 Like

this is really helpful

Hi all,

Running into the same issues so I thought I’d raise it as a bug. Please see below.

Backup restore failing on clean dev docker env: FATAL: Peer authentication failed for user “postgres”

Let me know if I can provide more info or be of any help.


Can’t get this to work openSUSE Leap 15. I suppose that’s not a supported OS, although since we’re using Docker it shouldn’t really matter…

Migrating database...
rake aborted!
Errno::EACCES: Permission denied @ dir_s_mkdir - /src/app/assets/javascripts/plugins
/src/lib/plugin/instance.rb:441:in `ensure_directory'
/src/lib/plugin/instance.rb:713:in `activate!'
lib/discourse.rb:283:in `block in activate_plugins!'
lib/discourse.rb:280:in `each'
lib/discourse.rb:280:in `activate_plugins!'
/src/config/application.rb:318:in `block in <class:Application>'
/src/lib/plugin_initialization_guard.rb:5:in `plugin_initialization_guard'
/src/config/application.rb:317:in `<class:Application>'
/src/config/application.rb:73:in `<module:Discourse>'
/src/config/application.rb:72:in `<main>'
/src/Rakefile:7:in `<main>'
(See full trace by running task with --trace)

Tried to just manually create “app/assets/javascripts/plugins” and that got me to

Migrating database...
rake aborted!
Errno::EACCES: Permission denied @ dir_s_mkdir - /src/tmp
lib/discourse.rb:94:in `atomic_write_file'
/src/lib/plugin/instance.rb:726:in `activate!'
lib/discourse.rb:283:in `block in activate_plugins!'
lib/discourse.rb:280:in `each'
lib/discourse.rb:280:in `activate_plugins!'
/src/config/application.rb:318:in `block in <class:Application>'
/src/lib/plugin_initialization_guard.rb:5:in `plugin_initialization_guard'
/src/config/application.rb:317:in `<class:Application>'
/src/config/application.rb:73:in `<module:Discourse>'
/src/config/application.rb:72:in `<main>'
/src/Rakefile:7:in `<main>'
(See full trace by running task with --trace)

So I’ll mkdir tmp in the source folder…

But then that gets me to here:

Migrating database...
rake aborted!
Errno::EACCES: Permission denied @ rb_sysopen - /src/tmp/5ad4443faf817dc922116f8df65ae5c3
lib/discourse.rb:97:in `initialize'
lib/discourse.rb:97:in `open'
lib/discourse.rb:97:in `atomic_write_file'
/src/lib/plugin/instance.rb:726:in `activate!'
lib/discourse.rb:283:in `block in activate_plugins!'
lib/discourse.rb:280:in `each'
lib/discourse.rb:280:in `activate_plugins!'
/src/config/application.rb:318:in `block in <class:Application>'
/src/lib/plugin_initialization_guard.rb:5:in `plugin_initialization_guard'
/src/config/application.rb:317:in `<class:Application>'
/src/config/application.rb:73:in `<module:Discourse>'
/src/config/application.rb:72:in `<main>'
/src/Rakefile:7:in `<main>'
(See full trace by running task with --trace)

It looks like boot_dev is running docker exec as the discourse user… but the directories are owned by a user 1016 (my host user’s uid).

I imagine a lot of devs don’t run into this problem on their personal laptops where their user has a uid of 1000 and it coincidentally lines up…

1 Like

Yikes d/cleanup is dangerous. That’s a good way to lose a lot of Docker work unrelated to Discourse at all…

I started doing some manual hacks like the following which were working but there kept being more and more permission issues, so I decided to stop trying to put out fires.

mkdir app/assets/javascripts/plugins
mkdir tmp
sudo chown 1000:1000 tmp
sudo chown 1000:1000 app/assets/javascripts/plugins

I’m going to use the host user with a uid of 1000 and I bet that it’s just going to work now, but this really exposes a shortcoming with how Discourse development is done it seems.

…and yep that did the trick.

In the case of that “tmp” that could be in a named or anonymous Docker volume. With the plugins, it could be useful to have that mounted volume but the host file system permissions would need to be altered to support writes.

I don’t think it’s safe to assume that every developer will be using a uid of 1000.


Hi guys, do you know how to run the development using old version discourse ? I know that in live discourse we can set version in app.yml. But I don’t know how to do it in development using docker. I want to run development on last stable version v2.7.10. Thanks for your help

Just checkout that branchor commit in git. (The way that I do it is to google

You’ll need to drop, create, and migrate the database after you downgrade.

Hi thanks @pfaffman ,

I did fresh git pull of discourse and checkout to “stable” version branch. (which is use discourse v2.7.10 tag)

I run dev init and set the admin user email and password

d/boot_dev --init

and run rails server it will listen on port 3000

d/rails s

then run ember-cli

cd app/assets/javascripts/discourse
yarn run ember serve --proxy "http://localhost:3000"

the discourse development can be open on “http://localhost:4200

however I got issue when login as admin user (the one that I created when run “d/boot_dev --init”)

“Unkown error” pop up showed on screen, with below error on /logs

ActiveRecord::StatementInvalid (PG::UndefinedFunction: ERROR:  function max(boolean) does not exist
LINE 1: ..._rank, MAX(user_badges.created_at) AS created_at, MAX(user_b...
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
lib/freedom_patches/ams_include_without_root.rb:49:in `include!'
app/controllers/application_controller.rb:495:in `serialize_data'
app/controllers/application_controller.rb:504:in `render_serialized'
app/controllers/session_controller.rb:611:in `login'
app/controllers/session_controller.rb:337:in `create'
app/controllers/application_controller.rb:395:in `block in with_resolved_locale'
app/controllers/application_controller.rb:395:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:71:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/missing_avatars.rb:23:in `call'
lib/middleware/turbo_dev.rb:34:in `call'

Do you have some experience with that error ? or maybe my step on running development on previous version was wrong ?

I think you need to rm -r the database. I’m not sure where it is, but it’s likely in the OP.

1 Like

Hi all,

Went fully clean slate again. All goes well, get a pristine development environment that I can log into.

Then I am getting a couple of plugins in to match my production environment and pull the most recent backup.

Upload it, try to restore it to the development environment and I get the Peer authentication error again. Have filed a bug, but so far there is no response. Can anyone try to reproduce? I’ve seen similar issues further op the comments to this post, so I figure I am not alone on this one?

[2021-11-29 19:43:39] 'koen' has started the restore!
[2021-11-29 19:43:39] Marking restore as running...
[2021-11-29 19:43:39] Making sure /src/tmp/restores/default/2021-11-29-194339 exists...
[2021-11-29 19:43:39] Copying archive to tmp directory...
[2021-11-29 19:43:39] Extracting dump file...
[2021-11-29 19:43:40] Validating metadata...
[2021-11-29 19:43:40]   Current version: 20211124161346
[2021-11-29 19:43:40]   Restored version: 20211123033311
[2021-11-29 19:43:40] Enabling readonly mode...
[2021-11-29 19:43:40] Pausing sidekiq...
[2021-11-29 19:43:40] Waiting up to 60 seconds for Sidekiq to finish running jobs...
[2021-11-29 19:43:46] Creating missing functions in the discourse_functions schema...
[2021-11-29 19:43:46] Restoring dump file... (this may take a while)
[2021-11-29 19:43:47] psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"
[2021-11-29 19:43:47] EXCEPTION: psql failed: psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"

[2021-11-29 19:43:47] /src/lib/backup_restore/database_restorer.rb:92:in `restore_dump'
/src/lib/backup_restore/database_restorer.rb:26:in `restore'
/src/lib/backup_restore/restorer.rb:51:in `run'
/src/script/spawn_backup_restore.rb:23:in `restore'
/src/script/spawn_backup_restore.rb:36:in `block in <main>'
/src/script/spawn_backup_restore.rb:4:in `fork'
/src/script/spawn_backup_restore.rb:4:in `<main>'
[2021-11-29 19:43:47] Trying to rollback...
[2021-11-29 19:43:47] There was no need to rollback
[2021-11-29 19:43:47] Cleaning stuff up...
[2021-11-29 19:43:47] Dropping functions from the discourse_functions schema...
[2021-11-29 19:43:47] Removing tmp '/src/tmp/restores/default/2021-11-29-194339' directory...
[2021-11-29 19:43:47] Unpausing sidekiq...
[2021-11-29 19:43:47] Marking restore as finished...
[2021-11-29 19:43:47] Notifying 'koen' of the end of the restore...
[2021-11-29 19:43:51] Finished!


I am having an issue that seems to stem from the schism between ports 3000 and 4200. I am not entirely sure how they related to each other, but my understanding is that 3000 is the server and 4200 a proxy to it from ember CLI. Port 4200 works well, except that sometimes, and specifically when responding with a 302, response headers have URIs that use port 3000 instead of 4200. I was specifically trying to get OAuth2 working with a custom provider as described here, and the presence of port 3000 in some of the responses breaks the OAuth2 workflow. There is no port 3000 in any of my OAuth2 configuration, it must be coming internally from the server.

Has anybody encountered this kind of issue before? Do you know how to set up an environment that mimics the production release more closely?

For what it’s worth, I also tried setting up the production release locally, but that requires a full-blown domain and email registration and doesn’t seem very friendly of local environments.

Thank you.

1 Like

Update, tried again to take the clean-slate route and this time using another machine. Now I get stuck because I do not have the UID 1000 which has been mentioned further up this thread, post 100 by @dcook. I would agree that assuming the UID=1000 is wrong and would constitute bug. Did you report it as such?

On my main machine the Postgress user permission bug persists which I did raise here: Backup restore failing on clean dev docker env: FATAL: Peer authentication failed for user “postgres”.

@rishabh what is your view on both these items? I loved switching over to the docker based method, quick and clean. But now on two different machines it feels a bit like a dead-end street and I am wondering what else I can contribute to get it resolved. Also wondering a bit on the lifecycle of bugs. Do they get received, reviewed, rejected or accepted, parked, resolved etc.?

I’ll for now go and try to set up the native dev environment see if I can get that working.


hello. this is my first time installing discourse using docker in mac.

first, i am sorry about my english … :sob:

I have already run

d/boot_dev --init

then I got error that port:3000 is already used. so I change port 30030:3000 (file : bin/docker/boot_dev)

after that, I start this code

d/boot_dev --init

# In one terminal:
d/rails s

# And in a separate terminal

my question is

  1. when I running d/rails s code. I can open discourse starting page on ‘localhost:30030’ . If I just want to open discourse and using 30030port (port forwarding), then Can I finish the install process?? I don’t know what is d/rails s, d/ember-cli. …

  2. and d/rail s process is sooo long. I am worried about what is wrong… is it right? or d/rails s and d/ember-cli is backgroud process while hosing discourse?

thank you. :bowing_man: