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
-
Download the version of Red you want to run (replace
3.6.8with the latest version):$ git clone --branch 3.6.8 https://git.nebendahl.eu/Mrcoolgamer11/Red-DiscordBot.git $ cd Red-DiscordBot -
Create the configuration file from the example:
$ cp .env.example .env -
Open
.envwith a text editor and set at leastRED_TOKEN(the token of your bot, see Creating a bot account) andRED_PREFIX. All settings are explained below. -
Build the image and start the bot:
$ docker compose up -d --buildOn 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 redPress
Ctrl+Cto 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) orpostgres. Only used when the instance is created on the first start, see Using PostgreSQL. RED_PLATFORMandRED_FLUXER_INSTANCE- Set
RED_PLATFORM=fluxerand 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-cogsor-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
redbotorredbot-setupcommands, 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) ortrue. 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.sockis 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)..envdoesn'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.
Installation Guides
- Installing Red
- Creating a bot account
- Updating Red
- Backing Up and Restoring Red
- About Virtual Environments
- Setting up auto-restart using batch on Windows
- Setting up auto-restart on Mac
- Setting up auto-restart using systemd on Linux
Cog Reference
User guides
- Getting started
- Running Red on Fluxer
- About Privileged Intents
- About public (big) bots
- Admin
- Alias
- Audio
- Cleanup
- Cog Manager UI
- Core
- CustomCommands
- Dev
- Downloader
- Economy
- Filter
- General
- Image
- Permissions
- Mod
- ModLog
- Mutes
- Reports
- Streams
- Trivia
- Warnings
- Red and End User Data
Cog Creation Guides
- Creating cogs for Red
- Slash Commands and Interactions
- Publishing cogs for Red
- Becoming an Approved Cog Creator
- Versioning
- End-user Guarantees
- Developer Guarantees
- Breaking Change Notices
Cog Development Framework Reference
- Shared API Keys
- Bank
- Bot
- Command Check Decorators
- App Command Check Decorators
- Commands Package
- App Commands Package
- Config
- Data Manager
- Custom Events
- Internationalization Framework
- Mod log
- RPC
- Tree
- Utility Functions
Others
Legacy (Red V2)