https://zero2CTFd.com/index.html

Installing CTFd inside of Docker on a RaspberryPI

Contents:
  1. Part 1. Update the system
  2. Part 2. Installing Docker
  3. Part 3. Install CTFd inside of Docker.
  4. Part 4. Accessing CTFd for the first time.
  5. Part 5. Verifying Your CTFd Installation and Useful Commands

Install Docker on Raspberry Pi

In this section, we will prepare a Raspberry Pi to run the CTFd platform. Because CTFd runs inside Docker containers, the first step is installing Docker and verifying that it works correctly on the system.


Part 1. Update the System

Before installing new software, it is always best practice to update the system package lists and install the latest available updates.

sudo apt update
sudo apt upgrade -y

2. Install Required Packages

Docker requires several supporting packages to install securely and download software from official repositories.

sudo apt install -y ca-certificates curl gnupg

Part 2. Installing Docker

The easiest way to install Docker on a Raspberry Pi is by using the official Docker installation script. This script automatically installs Docker Engine, containerd, and the Docker command line tools.

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

This installation will include:


4. Add Your User to the Docker Group

By default, Docker commands require administrative privileges. Adding your user account to the docker group allows you to run Docker commands without using sudo.

sudo usermod -aG docker $USER

Apply the change by running:

newgrp docker

Alternatively, you can log out and log back into the Raspberry Pi.

Workshop Tip

If Docker commands return a permission error, log out of the Raspberry Pi and log back in so the docker group membership takes effect.


5. Verify Docker is Installed

Confirm that Docker was installed successfully by checking the version.

docker --version

You should see output similar to:

Docker version 26.x.x

6. Test Docker with a Container

Run a simple test container to confirm that Docker is working correctly.

docker run hello-world

If the installation is working correctly, you will see a message similar to:

Hello from Docker!
This message shows that your installation appears to be working correctly.

7. Confirm Docker Starts on Boot

To ensure Docker automatically starts when the Raspberry Pi boots, enable the Docker service.

sudo systemctl enable docker
sudo systemctl start docker

You can verify the service status using:

sudo systemctl status docker

Once Docker is installed and running, the Raspberry Pi is ready for the next step: installing the CTFd platform inside a Docker container.


Part 3. Install CTFd Inside of Docker

Now that Docker is installed and running on the Raspberry Pi, the next step is to deploy the CTFd platform. The CTFd developers provide a ready-to-use Docker deployment package that allows the entire platform to start with only a few commands.

In this section, you will download the official deployment files and start the CTFd containers using Docker Compose.


1. Create a Folder for CTFd

First create a directory to store the CTFd files and move into that folder.

mkdir ~/CTFd
cd ~/CTFd

2. Download the Official CTFd Docker Deployment

Download the official Docker deployment package from the CTFd GitHub repository.

curl -LO https://github.com/CTFd/CTFd/archive/refs/heads/master.zip

Extract the archive and move into the directory.

sudo apt install -y unzip
unzip master.zip
cd CTFd-master

3. Start the CTFd Containers

Use Docker Compose to download the required container images and start the CTFd platform.

docker compose up -d

The first time this command runs, Docker will download several container images including the CTFd application, database, caching service, and web server. This process may take a few minutes depending on your internet connection.

Workshop Tip

The first startup may take several minutes while Docker downloads the required images. This is normal for the first run.


Part 4. Accessing CTFd for the First Time

Once the containers are running, the CTFd platform will be accessible through a web browser.


1. Find the Raspberry Pi IP Address

To determine the IP address of the Raspberry Pi, run the following command:

hostname -I

This command will display the network address assigned to the Raspberry Pi.


2. Open the CTFd Web Interface

Open a web browser and navigate to the Raspberry Pi's address.

http://<your-raspberry-pi-ip>

If you are working directly on the Raspberry Pi desktop, you may also use:

http://localhost

When the page loads, you should see the CTFd setup wizard.


3. Complete the Initial Setup

The setup wizard will guide you through creating the administrator account and configuring the competition platform. During this step you will define:

After completing the setup, you will be taken to the CTFd administration dashboard where challenges and users can be managed.


Part 5. Verifying Your CTFd Installation and Useful

Once the platform is running, it is useful to verify that the Docker containers are operating correctly and to understand a few commands used to manage the system.


1. Check Container Status

Use the following command to see the status of all CTFd containers.

docker compose ps

You should see several services running with a status of Up. These typically include:


2. View Container Logs

If something does not appear to be working correctly, logs can help identify the issue.

docker compose logs

To watch logs in real time, run:

docker compose logs -f

3. Stop the Platform

If you need to shut down the platform, use:

docker compose down

4. Start the Platform Again

To restart the containers, run:

docker compose up -d

5. Restart the Containers

If you make configuration changes or need to reload the system, you can restart the containers.

docker compose restart
Workshop Tip

If the CTFd website does not load, verify that the containers are running with docker compose ps and confirm the Raspberry Pi IP address with hostname -I.

At this point, your Raspberry Pi should be running a fully functional CTFd server ready to host challenges and participants.