GitPedia

Tf2 servers

TF2 server in Docker container - multiple images for various purposes

From melkortf·Updated June 18, 2026·View on GitHub·

**[Team Fortress 2 Dedicated Server](https://wiki.teamfortress.com/wiki/Linux_dedicated_server) Docker images for multiple purposes** The project is written primarily in Dockerfile, distributed under the MIT License license, first published in 2021. Key topics include: dedicated-game-server, docker, docker-image, srcds, tf2.

Latest release: 3.9.25Release 3.9.25
May 27, 2026View Changelog →

<img src="./images/logo.svg" align="right" alt="tf2-servers logo by bobair" width="170" height="170">

tf2-servers

<p> <a href="https://github.com/melkortf/tf2-servers/releases"> <img alt="Latest release" src="https://img.shields.io/github/v/release/melkortf/tf2-servers"> </a> <a href="https://github.com/melkortf/tf2-servers/actions/workflows/build.yml"> <img src="https://img.shields.io/github/actions/workflow/status/melkortf/tf2-servers/build.yml" alt="Build status"> </a> <a href="https://opensource.org/licenses/MIT"> <img src="https://img.shields.io/badge/license-MIT-d4c0bf.svg" alt="MIT license"> </a> </p>

Team Fortress 2 Dedicated Server Docker images for multiple purposes

$ docker run \
  -v "maps:/home/tf2/server/tf/maps" \
  -e "RCON_PASSWORD=foobar123" \
  -e "SERVER_HOSTNAME=melkor.tf" \
  -e "STV_NAME=melkor TV" \
  --network=host \
  ghcr.io/melkortf/tf2-base

Handling server.cfg

Each TF2 image has its own server.cfg.template file that is used to generate server.cfg. The docker container
uses envsubst to replace environment variables in the template file.
For example, this line in server.cfg.template:

rcon_password "${RCON_PASSWORD}"

when launched with these params:

$ docker run --network=host -e RCON_PASSWORD=123456 -itd ghcr.io/melkortf/tf2-base

will generate the following server.cfg:

rcon_password "123456"

There are many more configuration options, you will find them all listed below.

Maps

In order to make the image as small as possible, the only map shipped is cp_badlands. This also lets you maintain only one volume with all the maps and share it between all the containers. Just mount /home/tf2/server/tf/maps to your local directory that contains all the maps you need:

$ docker run -v "/your/maps/directory:/home/tf2/server/tf/maps" --network=host -d ghcr.io/melkortf/tf2-base

Network

The docker run examples in this readme run on the host network for best performance. Read official documentation on the host network driver here.

Command line arguments

The container entrypoint ensures the safe parameters are used to launch the TF2 server. These are, among others:

  • -steamcmd_script path,
  • -ip, -port, +clientport, -steamport and +tv_port options,
  • +sv_setsteamaccount env variable.

These are part of image internal scripts and cannot be overridden by other means than the environment variables. Other values, on the other hand, can be easily configured however desired. The default command line for the tf2-base image is

+sv_pure 1 +map cp_badlands +maxplayers 24

You can override these by simply appending command line to the docker run invocation, for example:

$ docker run -v "maps:/home/tf2/server/tf/maps" --network=host ghcr.io/melkortf/tf2-base +sv_pure 1 +map pl_badwater +maxplayers 24

This will start the server on pl_badwater.

Images

tf2-base

$ docker pull ghcr.io/melkortf/tf2-base
32-bit64-bit
ghcr.io/melkortf/tf2-base, ghcr.io/melkortf/tf2-base/i386ghcr.io/melkortf/tf2-base/amd64

The base image for all other images; pure TF2 server, without any add-ons and plugins.

Environment variableDefault valueUsed inDescription
IP0.0.0.0-ip ${IP}Specifies the address to use for the bind(2) syscall.
PORT27015-port ${PORT}The port which the server will run on.
CLIENT_PORT27016+clientport ${CLIENT_PORT}The client port.
STEAM_PORT27018-steamport ${STEAM_PORT}Master server updater port.
STV_PORT27020+tv_port ${STV_PORT}SourceTV port.
SERVER_TOKEN+sv_setsteamaccount ${SERVER_TOKEN}Game server account token to use for logging in to a persistent game server account.
RCON_PASSWORD123456rcon_password "${RCON_PASSWORD}"The RCON password (change this in your docker run invocation).
SERVER_HOSTNAMEA Team Fortress 2 serverhostname "${SERVER_HOSTNAME}"The game server hostname.
SERVER_PASSWORDsv_password "${SERVER_PASSWORD}"The server password.
STV_NAMESource TVtv_name "${STV_NAME}"SourceTV host name.
STV_TITLEA Team Fortress 2 server Source TVtv_title "${STV_TITLE}"Title for the SourceTV spectator UI.
STV_PASSWORDtv_password "${STV_PASSWORD}"SourceTV password.
DOWNLOAD_URLhttps://fastdl.serveme.tf/sv_downloadurl "${DOWNLOAD_URL}"Download URL for the FastDL.
ENABLE_FAKE_IP0-enablefakeipEnables/Disables SDR by turning the -enablefakeip flag on or off, setting to 1 or 0 respectively.

tf2-sourcemod

$ docker pull ghcr.io/melkortf/tf2-sourcemod
32-bit64-bit
ghcr.io/melkortf/tf2-sourcemod, ghcr.io/melkortf/tf2-sourcemod/i386ghcr.io/melkortf/tf2-sourcemod/amd64

TF2 server with Metamod:Source and SourceMod installed.

tf2-competitive

$ docker pull ghcr.io/melkortf/tf2-competitive
32-bit64-bit
ghcr.io/melkortf/tf2-competitive, ghcr.io/melkortf/tf2-competitive/i386-

TF2 server configured to be used in competitive matches. The following plugins, add-ons and configs are installed:

Environment variableDefault valueUsed inDescription
DEMOS_TF_APIKEYsm_demostf_apikey ${DEMOS_TF_APIKEY}The API key used to upload the demo to demos.tf.
LOGS_TF_APIKEYlogstf_apikey ${LOGS_TF_APIKEY}The API key used to upload logs to logs.tf.

tf2-dm

$ docker pull ghcr.io/melkortf/tf2-dm
32-bit64-bit
ghcr.io/melkortf/tf2-dm, ghcr.io/melkortf/tf2-dm/i386-

TF2 dedicated server for DeathMatch gameplay.

tf2-mge

$ docker pull ghcr.io/melkortf/tf2-mge
32-bit64-bit
ghcr.io/melkortf/tf2-mge, ghcr.io/melkortf/tf2-mge/i386-

TF2 dedicated server for MGE 1v1 training mod.

Contributors

Showing top 12 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from melkortf/tf2-servers via the GitHub API.Last fetched: 6/28/2026