8 Installing Red with Docker Compose
Forgejo Actions edited this page 2026-11-25 21:35:10 +00:00

This page is generated from docs/install_guides/docker.rst - please edit the source file instead of this page.

Installing Red with Docker Compose

Red can be run in a Docker container, using the Dockerfile and docker-compose.yml from the repository. This works on every system that supports Docker (Linux, Windows and macOS with Docker Desktop, x86-64 and aarch64). The image contains everything Red needs, including Java for the Audio cog and git for Downloader.

Installing the requirements

Install Docker Engine (Linux) or Docker Desktop (Windows, macOS) and make sure that Docker Compose is available:

$ docker compose version

You also need git to download Red's source code (or download it as an archive from the releases page).

Setting up the bot

  1. Download the version of Red you want to run (replace 3.6.8 with the latest version):

    $ git clone --branch 3.6.8 https://git.nebendahl.eu/Mrcoolgamer11/Red-DiscordBot.git
    $ cd Red-DiscordBot
    
  2. Create the configuration file from the example:

    $ cp .env.example .env
    
  3. Open .env with a text editor and set at least RED_TOKEN (the token of your bot, see Creating a bot account) and RED_PREFIX. All settings are explained below.

  4. Build the image and start the bot:

    $ docker compose up -d --build
    

    On the first start, the instance is created automatically. Follow the logs to see whether the bot started successfully - it shows an invite link for your bot once it's ready:

    $ docker compose logs -f red
    

    Press Ctrl+C to stop following the logs (the bot keeps running).

Continue with Getting started to learn how to use Red.

Settings

The bot is configured with the following settings in the .env file:

RED_TOKEN
The token of the bot. Required.
RED_PREFIX
The prefix(es) of the bot, separated by spaces. If set, it overrides the prefix set with [p]set prefix.
RED_OWNER
The ID of the bot's owner. Optional, defaults to the owner of the bot application.
RED_INSTANCE
The name of the instance. Defaults to red. Only change this before the first start.
RED_STORAGE
The storage backend, json (default) or postgres. Only used when the instance is created on the first start, see Using PostgreSQL.
RED_PLATFORM and RED_FLUXER_INSTANCE
Set RED_PLATFORM=fluxer and the URL of the Fluxer instance to run the bot on Fluxer instead of Discord, see Running Red on Fluxer.
RED_EXTRA_ARGS
Additional arguments for redbot, e.g. --no-cogs or -v.

After changing .env, apply the changes with docker compose up -d.

All data of the bot (the instance's configuration, cogs and their data) is stored in the red-data Docker volume, so it's kept when the container is recreated or updated.

Using PostgreSQL

The bot uses JSON files to store its data by default, which is recommended for most bots. To use PostgreSQL instead, set the following in .env before the first start:

RED_STORAGE=postgres
POSTGRES_PASSWORD=<a long random password>

and start the bot together with the included PostgreSQL container:

$ docker compose --profile postgres up -d --build

Always pass --profile postgres to the docker compose commands in this case. To use an external PostgreSQL server instead, set PGHOST, PGPORT, PGUSER, POSTGRES_PASSWORD and PGDATABASE in .env and start the bot without the profile.

Managing the bot

  • Stop the bot: docker compose stop
  • Start it again: docker compose start
  • Show the logs: docker compose logs -f red
  • Run redbot or redbot-setup commands, e.g. to create a backup:
    $ docker compose run --rm red redbot-setup backup red /data
    

NOTE

The container is restarted automatically when it stops, including after [p]restart and [p]shutdown. To stop the bot, use docker compose stop instead of [p]shutdown.

If the bot can't start because of a configuration error (e.g. an invalid token), it's restarted over and over again - check the logs, fix the configuration in .env and run docker compose up -d.

Updating the bot

To install updates automatically, see Automatic updates. Otherwise, read the changelog of the new version first (see Updating Red), then run (replace 3.6.8 with the version you want to update to):

$ git fetch --tags
$ git checkout 3.6.8
$ docker compose up -d --build

Third-party cogs are kept, but you should update them with [p]cog update afterwards.

Automatic updates

Red can install new releases automatically: the optional updater service checks for new releases every few hours, checks out the new version in the folder of Red, rebuilds the image and restarts the bot. The bot sends its owners a message after it has been updated.

To enable it, add the following to .env and run docker compose up -d:

COMPOSE_PROFILES=autoupdate

(if you use PostgreSQL, set COMPOSE_PROFILES=autoupdate,postgres instead). Follow what it does with docker compose logs -f updater.

The following settings can be changed in .env:

RED_AUTO_UPDATE_INTERVAL
The hours between update checks (default: 6).
RED_AUTO_UPDATE_MINOR
Whether to also install minor updates (e.g. from 3.6.x to 3.7.0), which may need manual steps that are described in their release notes - false (default) or true. Patch updates (e.g. from 3.6.8 to 3.6.8) are always installed.

Notes:

  • The updater needs access to Docker (/var/run/docker.sock is mounted into its container) to rebuild and restart the bot. Anyone who can change the files in the folder of Red can therefore run commands on the host - keep the folder only writable by you.
  • If the folder of Red has local changes to its files, no updates are installed (undo them with git stash). .env doesn't count, it's not part of the repository.
  • If a branch (e.g. V3/develop) is checked out instead of a release, the updater installs its new commits instead.