Migrate an old Discourse install to Docker

AI-generated summary

This guide, preserved for historical purposes, explains how to migrate a non-Docker Discourse installation to a Docker-based setup — now the recommended and universally used method by Discourse for hosting. The process begins by installing a fresh, empty Discourse instance via Docker, ensuring email is configured and working, and verifying container access via ./launcher enter. Key tips include binding the web server to a non-80 port initially (e.g., 81) to avoid conflicts, and setting DISCOURSE_DEVELOPER_EMAILS to gain admin access. Before exporting, users must update their old Discourse instance to the latest version to avoid known export bugs. The migration involves exporting a backup from the old site via /admin/backups, enabling the allow_restore setting on the new Docker instance, uploading the backup, and restoring it. Finally, users should switch the port binding back to 80 and rebuild the container with ./launcher rebuild app. Skipping any step may cause migration failure. The guide emphasizes Docker’s advantages: consistent configurations, easier troubleshooting, and elimination of common setup issues like misconfigured nginx or suboptimal Ruby defaults. All Discourse-hosted sites now run on Docker.

:information_source: 2022.10.21 @pfaffman adds: If you are somehow using a non-docker installation in 2022 then this guide might help you. There is not much way to test it, but it should work.

Kept for historical purposes

Deploying Discourse on Docker is currently our recommended setup. It avoids many pitfalls installations have, such as misconfigured nginx, sub-optimal Ruby defaults and so on.

The Docker based setup ensures we are all on the same page when diagnosing installation issues and completely eradicates a class of support calls.

Today, all sites hosted by Discourse are on Docker.

This is a basic guide on how to move your current Discourse setup to a Docker based setup.

Getting started

First, get a blank site with working email installed. Follow the guide at GitHub - discourse/discourse_docker: A Docker image for Discourse · GitHub and install a new, empty Discourse instance.

Tips:

  • Bind the web to a different port than port 80, if you are on the same box. Eg:

      expose:
        - "81:80"
    
  • Be sure to enter your email in the developer email section, so you get admin:

      env:
        # your email here
        DISCOURSE_DEVELOPER_EMAILS: 'my_email@email.com'
    
  • Make sure email is setup and working by visiting /admin/email and sending a test email.

  • Make sure you have can enter your container ./launcher enter my_container must work.

If any of the above is skipped your migration will fail.

At the end of this process you will have a working website. Carry on.

Exporting and importing the old site

  • Ensure you are running the absolute latest version of Discourse. We had bugs in the export code in the past, make sure you are on latest before attempting an export.

  • On your current instance

    • go to /admin/backups and click on the button.
    • once the backup is done, you will be able to it.
  • On your newly installed docker instance

    • enable the allow_restore site setting
    • refresh your browser for the change to be taken into account
    • go to /admin/backups and your backup.
    • once your upload is done, click on the button
  • Change port binding so its on 80

  • Rebuild container ./launcher rebuild app

Yay. You are done.

Last edited by @JammyDodger 2024-08-21T13:43:11Z

Check documentPerform check on document:
21 Likes