---
title: Run a container challenge
description: Build a Docker image on the platform and serve it to players as per-team instances.
---

In this tutorial you'll package a challenge as a Docker image, build it on the platform, and publish it as a container challenge: one where every team launches its own live instance with its own unique, dynamically generated flag.

:::warning[Not available on Extra Small events]
Extra Small events are for static challenges only. They have no image builds
and no challenge instances. You'll need an event sized **Small** or larger,
like the one from [Host your first CTF](/organizers/tutorials/host-your-first-ctf).
:::

1. **Prepare your build context**

    A build context is a zip archive containing a `Dockerfile` **at its
    root**, plus whatever your image needs. Any language or stack works. A
    minimal web challenge might look like:

    - Dockerfile
    - requirements.txt
    - app/
      - server.py
      - templates/
        - index.html

    When you zip it, make sure the `Dockerfile` sits at the top level of the
    archive, not inside a wrapping folder. The zip can be up to 100 MB.

    One thing to build in from the start: your challenge should read its flag
    from the `FLAG` or `FLAG_FULL` environment variable. The platform
    injects both into every instance (more on this in the dynamic-flag step
    below).

2. **Upload and build the image**

    Open **Image builds** in your event's sidebar. The page's **Build
    quota** card tracks the two limits every build counts against: **Docker
    storage** (used by successful builds' images) and **Build minutes**
    (consumed by every build run, including failed ones).

    Click **New build**:

    - **Name**: a lowercase identifier for the image, like `my-challenge`.
    - **Build context**: drag your zip onto the drop zone or use **Browse
      files**.
    - **Build args**: optional key/value pairs passed to the Docker build,
      via **Add**.

    Click **Upload and build**. The build appears in the table as
    **Queued**, then **Building**, and the page refreshes on its own until
    it lands on **Succeeded** or **Failed** (failed builds show a short
    error under the badge). A succeeded build's **Image** column shows a
    digest. Every build is pinned to its exact digest, so a challenge keeps
    serving precisely the image you tested even if you build again under the
    same name.

3. **Create a challenge with a dynamic flag**

    Create a challenge as in
    [Publish your first challenge](/organizers/tutorials/publish-your-first-challenge).
    Title, description, category, difficulty, and points all work the same.
    The difference is in the **Flags** section: set **Flag Type** to
    **Dynamic**.

    With a dynamic flag there's no flag content to type. The platform
    generates a fresh secret for each team the first time that team deploys the
    challenge, and that team keeps the same flag for the rest of the event,
    even across redeploys. Dynamic flags are always case-sensitive. That
    per-team secret is what reaches your container as environment variables:

    - `FLAG`: the generated secret, e.g. `f4k3s3cr3t123456`
    - `FLAG_FULL`: the wrapped form players submit, e.g.
      `athena{f4k3s3cr3t123456}`

    Your image decides how to expose it: print it after an exploit, plant it
    in a file, serve it from an admin page. Because every team's flag is
    different, flags shared between teams simply won't work.

4. **Configure the runtime**

    Choosing a dynamic flag reveals the **Runtime setup** section. As the
    form puts it: each instance runs all services together on one host,
    services reach each other via `127.0.0.1`, and up to 2 ports can be
    opened per instance, across at most **5 services**, with each port
    either web or TCP.

    Click **Add Service** and configure it:

    - **Name**: lowercase, like `web`. The first service defaults to
      `main`.
    - **Image**: pick one of your succeeded builds from the dropdown
      (they're listed by name and digest; only built images can be
      selected).
    - **Start command**: optional; overrides the image's default command,
      e.g. `python3 server.py --port 80`.
    - **Open ports**: use **Add port** for each port players connect to. Set
      its kind to **Web** for a browser or **TCP** for a raw socket. At most
      2 ports total across all services.
    - **Environment variables**: extra configuration for your container via
      **Add variable**. `FLAG` and `FLAG_FULL` are reserved; the platform
      sets them for you.

    You can add more services (a database next to the web app, say). They
    share the one host and its task size, and talk to each other over
    `127.0.0.1`.

    Once a service exists, a **Task size** selector appears. Small
    (0.25 vCPU / 512 MB) is the default and is enough for most challenges;
    the larger sizes cost proportionally more instance-hours, and how large
    you can go depends on the event's size. See
    [Challenge editor](/organizers/reference/challenge-editor).

5. **Publish and watch it run**

    Click **Create Challenge** (or **Publish Challenge** if you saved it as
    a draft first). On the player side, the challenge now offers instance
    controls instead of a static target: each team starts its own instance,
    gets its connection details, and can redeploy it if it fails or expires.
    The team's flag stays the same across redeploys.

    To see instances live, open **Running instances** in the sidebar. The
    **Challenge instances** table lists each session with its challenge,
    user, and status, and clicking a row shows the details, including the
    hostname players were given for each exposed port.

## Next steps

That's the full tutorial arc: a live event, a static challenge, and a
per-team container challenge. From here, the [how-to guides and
reference](/organizers) cover the rest of the organizer surface: branding,
player sign-in, release scheduling, live-event monitoring, and more.
