Introducing our new CEO Don Johnson - Read More

bitnami/discourse

Verified Publisher

By VMware

Updated 16 days ago

Bitnami container image for Discourse

Image
Helm
Content Management System
70

10M+

Discourse® packaged by Bitnami

What is Discourse®?

Discourse is an open source discussion platform with built-in moderation and governance systems that let discussion communities protect themselves from bad actors even without official moderators.

Overview of Discourse® Trademarks: This software listing is packaged by Bitnami. The respective trademarks mentioned in the offering are owned by the respective companies, and use of them does not imply any affiliation or endorsement.

TL;DR

docker run --name discourse bitnami/discourse:latest

Warning: This quick setup is only intended for development environments. You are encouraged to change the insecure default credentials and check out the available configuration options in the Environment Variables section for a more secure d eployment.

Why use Bitnami Images?

  • Bitnami closely tracks upstream source changes and promptly publishes new versions of this image using our automated systems.
  • With Bitnami images the latest bug fixes and features are available as soon as possible.
  • Bitnami containers, virtual machines and cloud images use the same components and configuration approach - making it easy to switch between formats based on your project needs.
  • All our images are based on minideb -a minimalist Debian based container image that gives you a small base container image and the familiarity of a leading Linux distribution- or scratch -an explicitly empty image-.
  • All Bitnami images available in Docker Hub are signed with Notation. Check this post to know how to verify the integrity of the images.
  • Bitnami container images are released on a regular basis with the latest distribution packages available.

Looking to use Discourse® in production? Try VMware Tanzu Application Catalog, the commercial edition of the Bitnami catalog.

Only latest stable branch maintained in the free Bitnami catalog

Starting December 10th 2024, only the latest stable branch of any container will receive updates in the free Bitnami catalog. To access up-to-date releases for all upstream-supported branches, consider upgrading to Bitnami Premium. Previous versions already released will not be deleted. They are still available to pull from DockerHub.

Please check the Bitnami Premium page in our partner Arrow Electronics for more information.

Supported tags and respective Dockerfile links

Learn more about the Bitnami tagging policy and the difference between rolling tags and immutable tags in our documentation page.

You can see the equivalence between the different tags by taking a look at the tags-info.yaml file present in the branch folder, i.e bitnami/ASSET/BRANCH/DISTRO/tags-info.yaml.

Subscribe to project updates by watching the bitnami/containers GitHub repo.

Get this image

The recommended way to get the Bitnami Discourse Docker Image is to pull the prebuilt image from the Docker Hub Registry.

docker pull bitnami/discourse:latest

To use a specific version, you can pull a versioned tag. You can view the list of available versions in the Docker Hub Registry.

docker pull bitnami/discourse:[TAG]

If you wish, you can also build the image yourself by cloning the repository, changing to the directory containing the Dockerfile and executing the docker build command. Remember to replace the APP, VERSION and OPERATING-SYSTEM path placeholders in the example command below with the correct values.

git clone https://github.com/bitnami/containers.git
cd bitnami/APP/VERSION/OPERATING-SYSTEM
docker build -t bitnami/APP:latest .

How to use this image

Discourse requires access to a PostgreSQL database to store information. We'll use the Bitnami Docker Image for PostgreSQL for the database requirements.

Using the Docker Command Line

Step 1: Create a network

docker network create discourse-network

Step 2: Create a volume for PostgreSQL persistence and create a PostgreSQL container

$ docker volume create --name postgresql_data
docker run -d --name postgresql \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --env POSTGRESQL_USERNAME=bn_discourse \
  --env POSTGRESQL_PASSWORD=bitnami123 \
  --env POSTGRESQL_DATABASE=bitnami_discourse \
  --network discourse-network \
  --volume postgresql_data:/bitnami/postgresql \
  bitnami/postgresql:latest

Step 3: Create a volume for Redis persistence and create a Redis container

$ docker volume create --name redis_data
docker run -d --name redis \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --network discourse-network \
  --volume redis_data:/bitnami/redis \
  bitnami/redis:latest

Step 4: Create volumes for Discourse persistence and launch the container

$ docker volume create --name discourse_data
docker run -d --name discourse \
  -p 8080:8080 -p 8443:8443 \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --env DISCOURSE_DATABASE_USER=bn_discourse \
  --env DISCOURSE_DATABASE_PASSWORD=bitnami123 \
  --env DISCOURSE_DATABASE_NAME=bitnami_discourse \
  --env DISCOURSE_HOST=www.example.com \
  --network discourse-network \
  --volume discourse_data:/bitnami/discourse \
  bitnami/discourse:latest

Step 5: Launch the Sidekiq container

docker run -d --name sidekiq \
  --network discourse-network \
  --volume discourse_data:/bitnami/discourse \
  bitnami/discourse:latest /opt/bitnami/scripts/discourse-sidekiq/run.sh

Access your application at http://your-ip/

Run the application using Docker Compose
curl -sSL https://raw.githubusercontent.com/bitnami/containers/main/bitnami/discourse/docker-compose.yml > docker-compose.yml
docker-compose up -d

Please be aware this file has not undergone internal testing. Consequently, we advise its use exclusively for development or testing purposes. For production-ready deployments, we highly recommend utilizing its associated Bitnami Helm chart.

If you detect any issue in the docker-compose.yaml file, feel free to report it or contribute with a fix by following our Contributing Guidelines.

Troubleshooting discourse

If you need to run discourse administrative commands like Create admin account from console, you can do so by executing a shell inside the container and running with the proper environment variables.

cd /opt/bitnami/discourse
RAILS_ENV=production bundle exec rake admin:create

Persisting your application

If you remove the container all your data will be lost, and the next time you run the image the database will be reinitialized. To avoid this loss of data, you should mount a volume that will persist even after the container is removed.

For persistence you should mount a directory at the /bitnami/discourse path. If the mounted directory is empty, it will be initialized on the first run. Additionally you should mount a volume for persistence of the PostgreSQL data.

The above examples define the Docker volumes named postgresql_data and discourse_data. The Discourse application state will persist as long as volumes are not removed.

To avoid inadvertent removal of volumes, you can mount host directories as data volumes. Alternatively you can make use of volume plugins to host the volume data.

Mount host directories as data volumes with Docker Compose

This requires a minor change to the docker-compose.yml file present in this repository:

   postgresql:
     ...
     volumes:
-      - 'postgresql_data:/bitnami/postgresql'
+      - /path/to/postgresql-persistence:/bitnami/postgresql
   ...
   redis:
     ...
     volumes:
-      - 'redis_data:/bitnami/redis'
+      - /path/to/redis-persistence:/bitnami/redis
   ...
   discourse:
     ...
     volumes:
-      - 'discourse_data:/bitnami/discourse'
+      - /path/to/discourse-persistence:/bitnami/discourse
   ...
   sidekiq:
     ...
     volumes:
-      - 'discourse_data:/bitnami/discourse'
+      - /path/to/discourse-persistence:/bitnami/discourse
   ...
-volumes:
-  postgresql_data:
-    driver: local
-  redis_data:
-    driver: local
-  discourse_data:
-    driver: local
Mount host directories as data volumes using the Docker command line

Step 1: Create a network (if it does not exist)

docker network create discourse-network

Step 2. Create a PostgreSQL container with host volume

docker run -d --name postgresql \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --env POSTGRESQL_USERNAME=bn_discourse \
  --env POSTGRESQL_PASSWORD=bitnami123 \
  --env POSTGRESQL_DATABASE=bitnami_discourse \
  --network discourse-network \
  --volume /path/to/postgresql-persistence:/bitnami/postgresql \
  bitnami/postgresql:latest

Step 3. Create a Redis container with host volume

docker run -d --name redis \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --network discourse-network \
  --volume /path/to/redis-persistence:/bitnami/redis \
  bitnami/redis:latest

Step 4. Create the Discourse container with host volumes

docker run -d --name discourse \
  -p 8080:8080 -p 8443:8443 \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --env DISCOURSE_DATABASE_USER=bn_discourse \
  --env DISCOURSE_DATABASE_PASSWORD=bitnami123 \
  --env DISCOURSE_DATABASE_NAME=bitnami_discourse \
  --env DISCOURSE_HOST=www.example.com \
  --network discourse-network \
  --volume /path/to/discourse-persistence:/bitnami/discourse \
  bitnami/discourse:latest

Step 5. Create the Sidekiq container with host volumes

docker run -d --name sidekiq \
  --network discourse-network \
  --volume /path/to/discourse-persistence:/bitnami/discourse \
  bitnami/discourse:latest

Configuration

Configuration files

You can mount your configuration files to the /opt/bitnami/discourse/mounted-conf directory. Make sure that your configuration files follow the standardized names used by Discourse. Some of the most common files include:

  • discourse.conf
  • database.yml
  • site_settings.yml

The set of default standard configuration files may be found here. You may refer to the the Discourse webpage for further details and specific configuration guides.

Environment variables

Customizable environment variables

NameDescriptionDefault Value
DISCOURSE_DATA_TO_PERSISTFiles to persist relative to the Discourse installation directory. To provide multiple values, separate them with a whitespace.plugins public/backups public/uploads
DISCOURSE_ENABLE_HTTPSWhether to enable HTTPS for Discourse by default.no
DISCOURSE_EXTERNAL_HTTP_PORT_NUMBERExternal HTTP port for Discourse.80
DISCOURSE_EXTERNAL_HTTPS_PORT_NUMBERExternal HTTPS port for Discourse.443
DISCOURSE_HOSTDiscourse host name.www.example.com
DISCOURSE_PORT_NUMBERPort number in which Discourse will run.3000
DISCOURSE_SKIP_BOOTSTRAPWhether to perform initial bootstrapping for the application.nil
DISCOURSE_SITE_NAMEDiscourse site name.My site!
DISCOURSE_ENVDiscourse environment mode. Allowed values: development, production, test.production
DISCOURSE_PRECOMPILE_ASSETSWhether to precompile assets during the initialization. Required when installing plugins.yes
DISCOURSE_ENABLE_CONF_PERSISTENCEWhether to enable persistence of the Discourse discourse.conf configuration file.no
DISCOURSE_EXTRA_CONF_CONTENTExtra configuration to append to the discourse.conf configuration file.yes
DISCOURSE_PASSENGER_SPAWN_METHODPassenger method used for spawning application processes. Valid values: direct, smart.direct
DISCOURSE_PASSENGER_EXTRA_FLAGSExtra flags to pass to the Passenger start command.nil
DISCOURSE_USERNAMEDiscourse user name.user
DISCOURSE_PASSWORDDiscourse user password.bitnami123
DISCOURSE_EMAILDiscourse user e-mail address.user@example.com
DISCOURSE_FIRST_NAMEDiscourse user first name.UserName
DISCOURSE_LAST_NAMEDiscourse user last name.LastName
DISCOURSE_SMTP_HOSTDiscourse SMTP server host.nil
DISCOURSE_SMTP_PORT_NUMBERDiscourse SMTP server port number.nil
DISCOURSE_SMTP_USERDiscourse SMTP server user.nil
DISCOURSE_SMTP_PASSWORDDiscourse SMTP server user password.nil
DISCOURSE_SMTP_PROTOCOLDiscourse SMTP server protocol to use.nil
DISCOURSE_SMTP_AUTHDiscourse SMTP authentication method. Allowed values: login, plain, cram_md5.login
DISCOURSE_SMTP_OPEN_TIMEOUTDiscourse smtp_open_timeout configuration override.nil
DISCOURSE_SMTP_READ_TIMEOUTDiscourse smtp_read_timeout configuration override.nil
DISCOURSE_DATABASE_HOSTDatabase server host.$DISCOURSE_DEFAULT_DATABASE_HOST
DISCOURSE_DATABASE_PORT_NUMBERDatabase server port.5432
DISCOURSE_DATABASE_NAMEDatabase name.bitnami_discourse
DISCOURSE_DATABASE_USERDatabase user name.bn_discourse
DISCOURSE_DATABASE_PASSWORDDatabase user password.nil
DISCOURSE_DB_BACKUP_HOSTDatabase backup server host.$DISCOURSE_DATABASE_HOST
DISCOURSE_DB_BACKUP_PORTDatabase backup server port.$DISCOURSE_DATABASE_PORT_NUMBER
DISCOURSE_REDIS_HOSTRedis(R) server host.$DISCOURSE_DEFAULT_REDIS_HOST
DISCOURSE_REDIS_PORT_NUMBERRedis(R) server port.6379
DISCOURSE_REDIS_PASSWORDRedis(R) user password.nil
DISCOURSE_REDIS_USE_SSLWhether to enable SSL for Redis(R).no
DISCOURSE_REDIS_DBRedis(R) database number.0

Read-only environment variables

NameDescriptionValue
DISCOURSE_BASE_DIRDiscourse installation directory.${BITNAMI_ROOT_DIR}/discourse
DISCOURSE_CONF_FILEConfiguration file for Discourse.${DISCOURSE_BASE_DIR}/config/discourse.conf
YARN_CACHE_FOLDERYarn cache folder${DISCOURSE_BASE_DIR}/tmp/cache
DISCOURSE_VOLUME_DIRDiscourse directory for mounted configuration files.${BITNAMI_VOLUME_DIR}/discourse
DISCOURSE_DAEMON_USERDiscourse system user.discourse
DISCOURSE_DAEMON_GROUPDiscourse system group.discourse
DISCOURSE_DEFAULT_DATABASE_HOSTDefault database server host.postgresql
DISCOURSE_DEFAULT_REDIS_HOSTDefault Redis(R) server host.redis

When you start the Discourse image, you can adjust the configuration of the instance by passing one or more environment variables either on the docker-compose file or on the docker run command line. If you want to add a new environment variable:

  • For docker-compose add the variable name and value under the application section in the docker-compose.yml file present in this repository:

    discourse:
      ...
      environment:
        - DISCOURSE_PASSWORD=my_password
      ...
    
  • For manual execution add a --env option with each variable and value:

    $ docker run -d --name discourse -p 80:8080 -p 443:8443 \
      --env DISCOURSE_PASSWORD=my_password \
      --network discourse-tier \
      --volume /path/to/discourse-persistence:/bitnami \
      bitnami/discourse:latest
    

Examples

SMTP configuration using a Gmail account

This would be an example of SMTP configuration using a Gmail account:

  • Modify the environment variables used for the discourse and sidekiq containers in the docker-compose.yml file present in this repository:

      discourse:
        ...
        environment:
          ...
          - DISCOURSE_SMTP_HOST=smtp.gmail.com
          - DISCOURSE_SMTP_PORT=587
          - DISCOURSE_SMTP_USER=your_email@gmail.com
          - DISCOURSE_SMTP_PASSWORD=your_password
          - DISCOURSE_SMTP_PROTOCOL=tls
      ...
      sidekiq:
        ...
        environment:
          ...
          - DISCOURSE_SMTP_HOST=smtp.gmail.com
          - DISCOURSE_SMTP_PORT=587
          - DISCOURSE_SMTP_USER=your_email@gmail.com
          - DISCOURSE_SMTP_PASSWORD=your_password
          - DISCOURSE_SMTP_PROTOCOL=tls
      ...
    
  • For manual execution:

    • First, create the Discourse container:

      $ docker run -d --name discourse -p 80:8080 -p 443:8443 \
        --env DISCOURSE_DATABASE_USER=bn_discourse \
        --env DISCOURSE_DATABASE_NAME=bitnami_discourse \
        --env DISCOURSE_SMTP_HOST=smtp.gmail.com \
        --env DISCOURSE_SMTP_PORT=587 \
        --env DISCOURSE_SMTP_USER=your_email@gmail.com \
        --env DISCOURSE_SMTP_PASSWORD=your_password \
        --env DISCOURSE_SMTP_PROTOCOL=tls \
        --network discourse-tier \
        --volume /path/to/discourse-persistence:/bitnami \
        bitnami/discourse:latest
      
    • Then, create the Sidekiq container:

      $ docker run -d --name sidekiq \
        --env DISCOURSE_DATABASE_USER=bn_discourse \
        --env DISCOURSE_DATABASE_NAME=bitnami_discourse \
        --env DISCOURSE_SMTP_HOST=smtp.gmail.com \
        --env DISCOURSE_SMTP_PORT=587 \
        --env DISCOURSE_SMTP_USER=your_email@gmail.com \
        --env DISCOURSE_SMTP_PASSWORD=your_password \
        --env DISCOURSE_SMTP_PROTOCOL=tls \
        --networ
      
      

Note: the README for this container is longer than the DockerHub length limit of 25000, so it has been trimmed. The full README can be found at https://github.com/bitnami/containers/blob/main/bitnami/discourse/README.md

Docker Pull Command

docker pull bitnami/discourse
Bitnami