Easily Deploy Red-DiscordBot via Docker

Easily Deploy Red-DiscordBot via Docker
Image from Red-DiscordBot

In this post, I'll be covering the basic things needed to get up and running with your own customizable Discord Bot.

Register an Application

First thing's first, you need a Discord Application with a Bot Token. To get started, head on over to the Discord Developer Portal and sign in.

Once logged in, click the New Application button in the top right corner of the screen. Give the application a Name, ensure the correct Team is selected (by default this should be just your username or Personal), then check the checkbox stating you agree to the Discord Developer Terms of Service and the Developer Policy.

0:00
/0:11

Demonstration on how to create an Application on Discord

Creating & Obtaining Discord Bot Token

Once the Application is created, you'll be directed to that application's General Information section. From here, select Bot from the NavBar on the left.

Now on the Bot page, look beneath the Build-A-Bot section to find your Bot's Token. You will likely need to click the Reset Token button to retrieve the token. If you lose this token for whatever reason, you'll have to come back to this page to reset it entirely.

⚠️
Safeguard this token like you would a password. Tokens bypass Discord's standard login process.
0:00
/0:13

Demonstration of how to obtain a Discord Bot Token

Enabling Privileged Gateway Intents

In order for Red to work properly, you need to ensure the following is enabled on the Bot page:

  • Presence Intent
  • Server Members Intent
  • Message Content Intent
💡
Note that if your bot reaches 100 or more servers, this will require verification and approval. You're unlikely to run into this, but keep this in mind.
0:00
/0:09

Getting Started with Docker

With all the Discord prerequisites out of the way, we can now move on to getting started with Docker.

First, you'll need a machine to run Docker and host the bot itself. This could be your Windows PC, a Virtual Machine, a VPS/VDS or even a Ras-Pi. I'll focus on two methods in this post: Docker on Windows and Docker on Ubuntu.

💡
If you want your bot to be running all the time, I suggest running this on a VPS from a hosting provider to maximize uptime and stability.

Docker on Windows

To install the Docker Desktop app on Windows, follow this guide.

Once installed, there's two ways to get started with Red.

  1. Deploy with Docker Desktop GUI
  2. Deploy with Docker Compose (recommended)

Deploying with Docker Desktop (GUI)

  1. Launch Docker Desktop
  2. In the Search bar at the top of the application, search "PhasecoreX"
  3. Select phasecorex/red-discordbot:latest
  4. Click Pull on the right-hand side of the window
  5. Once the image is pulled, click Run
  6. In the Run a new container window, drop down the Optional settings
  7. Give the container a name
  8. Under Volumes, define the following:
    Host Path: Location where data will be stored. I created a folder on my Desktop for this. You can use the three dot menu to browse a location.
    Container Path: This value must be set to /data
  9. Under Environment Variables, define the following: (Variable / Value)
    TOKEN / [bot token]
    PREFIX / . (can be any string)
  10. Click Run

The Docker Container should then be created and you should see the log output. After a few moments, you should see a link that can be used to invite the bot to your server. Huzzah!

0:00
/1:07

Demonstration on getting Red running via Docker Desktop (GUI)

  1. Create a folder in a known location (your Desktop, for example) and create a file named docker-compose.yml inside that folder
    a. You can also download this file if you want and can skip step 2
  2. Paste the following into the docker-compose.yml file:
version: "3.2"
services:
  redbot:
    container_name: redbot
    image: phasecorex/red-discordbot
    restart: unless-stopped
    volumes:
      - ./redbot:/data
    environment:
      - TOKEN=your_bot_token_goes_here
      - PREFIX=.
      - TZ=America/Detroit
      - PUID=1000
  1. Edit the TOKEN variable and replace the value with your bot's token
  2. Change the PREFIX and TZ variable if desired
  3. Once done editing the file, save it and close your editor
  4. Launch Powershell (or Terminal) and cd into the folder we just created
    a. For example, cd c:\Users\username\Desktop\Red-DiscordBot
    b. If your username or path contains any spaces, you'll need to use quotes around the path
  5. Type the following: docker compose up (you may append -d to the end of this command if you want the container to be created and ran in the background)
  6. If everything goes to plan, Docker should pull the image and create the container. Huzzah!
0:00
/1:17

Using Docker Compose to pull and create the Red-DiscordBot container

Docker on Ubuntu

This part of the post is coming soon. However, if using docker compose, it's basically the same exact process as above. Put the docker-compose.yml file in a directory, cd into it, then run docker-compose up -d from Terminal. This assumes you have Docker and Docker Compose installed on the system.

For Ubuntu, the package names are docker.io and docker-compose.

Voila! You're done!

See? It's super easy to get started with Red once you get the container up and running. As the terminal log suggests, take a loot at https://start.discord.red for a quick guide on setting up Red.