Install Discourse for development using Docker

There is no way to docker Discourse on a Mac with a M1 chip currently right?

When running d/boot_dev --init, I was running into this error:

ActiveRecord::NoDatabaseError: We could not find your database: discourse_development. Available database configurations can be found in config/database.yml. (ActiveRecord::NoDatabaseError)

Iā€™m not sure if this is a bug in the boot_dev script, or if the discourse_development database is supposed to be created somewhere else. Either way, I was able to fix it with this change:

diff --git a/bin/docker/boot_dev b/bin/docker/boot_dev
index 89fdcf6f65..0e9c5ce7d5 100755
--- a/bin/docker/boot_dev
+++ b/bin/docker/boot_dev
@@ -122,6 +122,7 @@ echo "pnpm install..."
 
 if [ "${initialize}" = "initialize" ]; then
     echo "Migrating database..."
+    "${SCRIPTPATH}/rake" db:create
     "${SCRIPTPATH}/rake" db:migrate
     RAILS_ENV=test "${SCRIPTPATH}/rake" db:migrate

After that, the setup process ran properly, following the instructions in the OP.

Iā€™m not familiar enough with the Discourse codebase to know whether this is the correct fix, but Iā€™m happy to submit a PR if that would help. :slightly_smiling_face:

5 Likes

Oh yes please create a PR and link it here. Thanks!

3 Likes

Done!

2 Likes

Any luck with getting it to run?

I got this same error. I ran docker rm -f /discourse_dev and re-ran d/boot_dev --init and it worked this time.

Heads up:
Iā€™ve just noticed the folder is data/postgres instead of tmp/postgres, which is also why the ā€œreset databaseā€ command aims to delete the data folder :slight_smile:

2 Likes

I thought Iā€™d give the docker dev install another look, but keep getting:

Caused by:
PG::ConnectionBad: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory (PG::ConnectionBad)
        Is the server running locally and accepting connections on that socket?

Yet I can confirm the service is up (and works when using my normal non-docker ā€œmanualā€ install of discourse)

~/discourse_docker/discourse$ sudo service postgresql status
ā— postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
     Active: active (exited) since Mon 2025-03-10 17:26:13 GMT; 6min ago
    Process: 2052109 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
   Main PID: 2052109 (code=exited, status=0/SUCCESS)

Mar 10 17:26:13 black-knight systemd[1]: Starting PostgreSQL RDBMS...
Mar 10 17:26:13 black-knight systemd[1]: Finished PostgreSQL RDBMS.

Does Docker Dev have specific and different Postgres connectivity needs?

1 Like

I found the default :debug log levels to be way too verbose - the SQL queries drown out important errors. config/environments/development.rb allows for the setting of the DISCOURSE_DEV_LOG_LEVEL, but I donā€™t know if this can be done through the d/rails script?

Anyway I just temporarily hard coded it in config/environments/development.rb to config.log_level = :info and that solved the problem for me. Might help others as well.

1 Like

Iā€™m trying to spin this up with the Data Explorer plugin because Iā€™d like to poke at the DE automation.

I got the container to start.

Then stumbled through ā€œinstallingā€ the plugin by cloning the repo and symlinking it into the disourse/plugins directory (is that what I was supposed to do? The guide really could be a lot clearer on that point).

I enabled the plugin through the UI. But when I try to access it, I get an error.

All that shows up in the log is this:

Processing by DiscourseDataExplorer::QueryController#index as JSON
Completed 500 Internal Server Error in 62ms (ActiveRecord: 9.8ms (5 queries, 0 cached) | GC: 2.9ms)

What am I supposed to do with this? Where are the details?

1 Like

Have you run the migrations?

I did not have very good luck with symlinking my plugins folder:

I ended up moving to a normal folder as a result (see my last comment in that thread).

I think there are some incompatibilities currently with Docker volumes, file watchers, and symlinks.

2 Likes

Thanks for the reply @Arkshine! What should have alerted me that this needed doing? I did check the tutorial on installing a plugin, but I guess the plugin the tutorial uses as an example doesnā€™t need migrations?

In the meantime, I donā€™t know if this gets me over the hump because Iā€™ve run smack into needing to get my companyā€™s proxy cert into the Docker container & I havenā€™t done much with Docker before :frowning:

What problem are you solving? A development install is generally intended to be accessible only to the localhost (i.e., your computer) where the install is running.

Or maybe youā€™re trying to debug something that requires a cert like an auth system?

When I tried to start my image back up yesterday, it wanted to download gems?

Installing gems...
Fetching source index from https://rubygems.org/

Retrying fetcher due to error (2/4): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification. For information about OpenSSL certificates, see https://railsapps.github.io/openssl-certificate-verify-failed.html.

Retrying fetcher due to error (3/4): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification. For information about OpenSSL certificates, see https://railsapps.github.io/openssl-certificate-verify-failed.html.

Retrying fetcher due to error (4/4): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification. For information about OpenSSL certificates, see https://railsapps.github.io/openssl-certificate-verify-failed.html.

Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have
the CA certificates needed for verification. For information about OpenSSL certificates, see
https://railsapps.github.io/openssl-certificate-verify-failed.html.