1
0
Fork 0
mirror of https://github.com/Jackzmc/docker-l4d2-server.git synced 2026-03-29 19:54:00 -05:00
Dockerized Left 4 Dead 2 Server
  • Dockerfile 54.7%
  • Shell 45.3%
Find a file
2026-02-16 22:11:03 -06:00
base Add lib32stdc++6 2026-02-16 22:11:03 -06:00
custom Add custom variant 2025-06-14 20:58:41 -05:00
.dockerignore Remove sourcemod, cleanup 2024-11-07 12:58:27 -06:00
.gitignore Switch to using external steamcmd install 2024-11-06 21:35:17 -06:00
build.sh Fix steamcmd with freetodownload issue 2025-06-14 20:43:55 -05:00
LICENSE.md initial? 2020-02-03 01:29:51 +00:00
README.md Improve README 2025-06-15 08:34:17 -05:00

Left 4 Dead 2 Dedicated Server in Docker

Running srcds in a docker container. Designed for Left 4 Dead 2, but should work for other source games.

Some code and implementations taken from:

Docker hub image

DockerHub Dockerfile

docker pull jackzmc/srcds-l4d2:base

Notes

  • The container will run as root, sourcemod should be installed externally and bind mounted.
  • The default entrypoint is /bin/bash -c with no arguments, see examples below.
  • The image contains the full game installed by steamcmd, it will not auto download updates.

Args

# Appid of dedicated server
ARG APPID=222860
# Folder name for game within $SERVER_DIR
ARG APPNAME=left4dead2  
# Where server runs from
ARG SERVER_DIR=/server
# For custom variant, the namespace to build from
ARG NAMESPACE=jackzmc

Envs

APPID - from arg
APPNAME - from arg (folder within $SERVER_DIR)
SERVER_DIR

Examples

# Generic Server
docker run -it -p 27015:27015 -p 27015:27015/udp jackzmc/srcds-l4d2:base ".-game left4dead2 -usercon +map c8m1_apartment"
# add extra cvars at the end

# Setting hostname or any variables with spaces
# You should enclose it with quotes (\"), for example:
docker run -it -p 27015:27015 -p 27015:27015/udp jackzmc/srcds-l4d2:base ./srcds_linux -usercon +hostname "\"My Server With Spaces\""

# Versus Server
docker run -it -p 27015:27015 -p 27015:27015/udp jackzmc/srcds-l4d2:base ./srcds_linux -usercon +map c8m1_apartment versus +sv_gametypes "VERSUS" 

# Run a server with custom addons / sourcemod (external)
docker run -it -p 27015:27015 -p 27015:27015/udp -v /home/steam/l4d2/addons:/server/left4dead2/addons -vjackzmc/srcds-l4d2:sourcemod ./srcds_linux -usercon +map c8m1_apartment 

Building Docker Images

The game files are downloaded externally with steamcmd, this way if you need to change the Dockerfile, you don't need to wait for the entire game to be redownlaoded every time. The dockerfile pulls from srcds_cache, a script to automatically setup steamcmd, install the game, and build the image is provided: build.sh

See the SteamCMD documentation for any dependencies needed: https://developer.valvesoftware.com/wiki/SteamCMD#Manually

You can use steamcmd to download to srcds-cache with this command, or just run update.sh which will download steamcmd & install for you: steamcmd.sh +login aonymous +force_install_dir /path/to/dockerfile/srcds-cache +app_update 222860 +quit