Docker Compose Community Spotlight: CTFd

This week, we’re looking at CTFd, an open source CTF (Capture the Flag) platform that you can run with Docker Compose.

/images/blog/cover-images/Spotlight-ctfd.png
CTFd and docker compose

by on

Welcome to Shipyard’s Docker Compose Community Spotlight series! During this series, we’ll feature a new Docker Compose-enabled open source project every week, show you how to run it on Shipyard, and how to contribute. This week, we’ll be featuring CTFd.

CTFd

License

CTFd is an open source CTF platform, in which you can create your own custom challenges and view live charts and scoreboards. A CTF (Capture the Flag) is a series of puzzles that participants compete to solve. Generally, they’re employed as an exercise in cybersecurity, but can cover a range of domains, from jeopardy-style questions to programming puzzles. If you’re interested in practicing your CTF skills, head on over to CTFlearn.

CTFd dashboard with statistics on solve count

You can run CTFd locally by cloning the repo and using the docker compose up command. Below, we’ll show you how to get your own copy up and running in an ephemeral environment.

CTFd Alternatives

CTFd is a free, self-hosted, and open source platform. Popular alternatives include:

Alternative Platform Pricing
Hack the Box Web Free tier
BlueRing Web Free tier
FacebookCTF Self-hosted Open source

If you’re reading this and know of another alternative, please reach out to us at hello@shipyard.build – we would love to feature it!

Running CTFd on Shipyard

If you’d like to start iterating on your own copy of CTFd, create a fork of the repository. We recommend you use an environments platform to test and run as you iterate. Shipyard is a straightforward, quick, and convenient solution.

Step 1: Modifying the Compose File

First, we’ll open the Docker Compose file and add three things to make it Shipyard-compatible. Since CTFd has multiple services, we’ll want to add a shipyard.route label to the main service:

services:
  ctfd:
    build: .
    user: root
    labels:
      shipyard.route: '/'
    restart: always
    ports:
      - "8000:8000"

Next, we’ll ensure all services have ports listed. The default MariaDB port is 3306, so we’ll add that to the db service:

db:
    image: mariadb:10.4.12
    restart: always
    ports:
      - 3306

We’ll also add the default Redis port (which is port 6379) to the cache service:

cache:
    image: redis:4
    ports:
      - 6379

And that’s it! You now have a Shipyard-ready Compose file!

Step 2: Accessing on Shipyard

Once we have our valid Compose file, we can create a new application on Shipyard using our forked CTFd repo. Shipyard will build the app using our Docker Compose application definition.

If you’d like to read more about running a Docker Compose-enabled app on Shipyard, check out our docs here.

Contributing to CTFd

If you’d like to begin contributing to CTFd, check out their contribution guide on GitHub. Once you’re familiar with CTFd’s contributor rules, you can browse open issues and begin iterating on a branch. When you open a PR, you can preview your changes in an ephemeral environment on Shipyard to test your branch and ensure it’s ready for merging.

And that’s a wrap! Thanks for checking out this week’s Docker Compose Community Spotlight! Stay tuned for next week’s featured open source app. If you’re ready to try out this app in an ephemeral environment, kick off a free Shipyard account here and go to the project’s repository here. Happy coding!

Try Shipyard today

Get isolated, full-stack ephemeral environments on every PR.

What is Shipyard?

Shipyard is the Ephemeral Environment Self-Service Platform.

Automated review environments on every pull request for Developers, Product, and QA teams.

Stay connected

Latest Articles

Shipyard Newsletter
Stay in the (inner) loop

Hear about the latest and greatest in cloud native, container orchestration, DevOps, and more when you sign up for our monthly newsletter.