/cod4-docker

Runs a Call of duty 4 Modern Warfare (cod4x) dedicated server in a Docker container.

Primary LanguageGoMIT LicenseMIT

COD4 Docker dedicated server

Call of duty 4 dedicated server in a 24MB Docker image

Docker Cod4

Build status Docker Pulls Docker Stars

GitHub last commit GitHub commit activity GitHub issues

Image size Image version Join Slack channel

Donate PayPal

Requirements

  • COD4 Client game
  • COD4 running on version 1.7 have to update to 1.8-19.0
  • Original COD4 main and zone files required (from the client installation directory)

⚠️ Version v19.x and up requires to bind mount zone without read only :ro

Features

  • Cod4x server features
  • Works with custom mods and maps (see the Mods section)
  • Built-in HTTP file server for usermaps and mods (only works with .ff and .iwd files for security reasons)
  • Runs without root (safer)
  • Default cod4 configuration file server.cfg when not using mods, with exec server.cfg
  • Multiple Docker images
    • qmcgaw/cod4:steam:
      • 368MB and based on Debian Buster Slim
      • Works with the cod4x masterlist
      • Cod4x server built from source statically
      • Other Cod4x files server downloaded from cod4x.me
    • qmcgaw/cod4, qmcgaw/cod4:alpine:
      • Only 24MB and based on Alpine 3.12
      • Does not work with the cod4x masterlist, see this
      • Cod4x server built from source statically
    • For each Github release tag there are two Docker images built:
      • :<tag-name> is the Alpine based image
      • :<tag-name>-steam is the larger Debian based image which supports steam and other features
    • Feel free to open an issue for another Docker tag if you need one

Setup

We assume your call of duty 4 game is installed at /mycod4path

  1. On your host, create the directories ./main, ./zone, ./mods and ./usermaps.

  2. From your Call of Duty 4 installation directory:

    • Copy all the .iwd files from /mycod4path/main to ./main
    • Copy all the files from /mycod4path/zone to ./zone
    • (Optional) Copy the mods you want to use from /mycod4path/mods to ./mods
    • (Optional) Copy the maps you want to use from /mycod4path/usermaps to ./usermaps
  3. As the container runs as user ID 1000 by default, fix the ownership and permissions:

    chown -R 1000 main mods usermaps zone
    chmod -R 700 main mods usermaps zone

    You can also run the container with --user="root" (unadvised!) if this doesn't work

  4. Run the following command as root user on your host:

    docker run -d --name=cod4 -p 28960:28960/tcp -p 28960:28960/udp -p 8000:8000/tcp \
        -v /mycod4path/main:/home/user/cod4/main \
        -v /mycod4path/zone:/home/user/cod4/zone \
        -v /mycod4path/mods:/home/user/cod4/mods \
        -v /mycod4path/usermaps:/home/user/cod4/usermaps:ro \
        qmcgaw/cod4 +map mp_shipment

    The command line argument +map mp_shipment is optional and defaults to +set dedicated 2+set sv_cheats "1"+set sv_maxclients "64"+exec server.cfg+map_rotate

    You can also download and modify the docker-compose.yml file and run

    docker-compose up -d

HTTP server for custom mods and maps

By default, the container runs with an HTTP file server for mods and usermaps on port 8000.

  • You can disable it with -e HTTP_SERVER=off
  • You can change its published port with for example -p 9000:8000/tcp
  • You can change its root URL with for example -e ROOT_URL=/cod4. This is useful if you use a reverse proxy.
  1. Locate the relevant cod4 configuration file - for example main/server.cfg or mods/mymod/server.cfg

  2. Modify/add the following lines & change youraddress to your IP or domain name:

    set sv_allowdownload "1"
    set sv_wwwDownload "1"
    set sv_wwwBaseURL "http://youraddress:8000" // supports http, https and ftp addresses
    set sv_wwwDlDisconnected "0"
  3. Feel free to open an issue for help setting this up, such as port forwarding or reverse proxy setup help

Update your game

  1. Make sure you updated your game to version 1.7 first (see this)
  2. Download the COD4x client ZIP file
  3. Using Winrar / 7Zip / Winzip, extract cod4x_client_19_0.zip to your COD4 game directory
  4. Go in the extracted directory cod4-client-manualinstall_19.0 and double click on install.cmd
  5. When launching the multiplayer game, you should see at the bottom right 19.0

Testing

  1. Make sure you updated your COD4 Game to 1.8-19.0
  2. Launch the COD4 multiplayer game
  3. Click on Join Game
  4. Click on Source at the top until it's set on Favourites
  5. Click on New Favourite on the top right
  6. Enter your host LAN IP Address (i.e. 192.168.1.26)
    • Add the port if you run it on something else than port UDP 28960 (i.e. 192.168.1.26:28961)
  7. Click on Refresh and try to connect to the server in the list

COD4 screenshot

Mods

Assuming:

  • Your mod directory is ./mymod
  • Your main mod configuration file is ./mymod/server.cfg

Set the command line option to +set dedicated 2+set sv_cheats "1"+set sv_maxclients "64"+set fs_game mods/mymod+exec server.cfg +map_rotate

Write protected args

The following parameters are write protected and can't be placed in the server configuration file, and must be in the command passed to the container:

  • +set dedicated 2 - 2: open to internet, 1: LAN, 0: localhost
  • +set sv_cheats "1" - 1 to allow cheats, 0 otherwise
  • +set sv_maxclients "64" - number of maximum clients
  • +exec server.cfg if using a configuration file
  • +set fs_game mods/mymod if using a custom mod
  • +set com_hunkMegs "512" don't use if not needed
  • +set net_ip 127.0.0.1 don't use if not needed
  • +set net_port 28961 don't use if not needed
  • +map_rotate OR i.e. +map mp_shipment should be the last launch argument

By default, the Docker image uses this command.

TODOs

  • UDP proxy for Windows
  • Reload ability of cod4x
  • Docker Healthcheck + HTTP healthcheck endpoint (i.e. for K8s)
  • Add extra ping with udp proxy
  • More env variables
    • Plugins
  • Plugins
  • Built-in mods?

Acknowledgements

  • Credits to the developers of Cod4x server
  • The help I had on Cod4x.me forums