cron410 / cod4-docker

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

COD4 Docker dedicated server

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

Docker Cod4

Cod4x build

Build Status

Docker build

Build Status Docker Build Status

GitHub last commit GitHub commit activity GitHub issues

Docker Pulls Docker Stars Docker Automated

Download size Image size RAM usage CPU usage
105.4MB 305MB 300MB to 400MB Low

It is based on:

  • Cod4x Linux Server
  • Debian stretch slim
  • g++-multilib

Requirements

  • COD4 Client game running on Windows
  • COD4 running on version 1.7 have to update to 1.8
  • Original COD4 main and zone files required

Features

  • Cod4x server features
  • Works with custom mods and maps (see the Mods section)
  • Easily configurable with docker-compose
  • Run a lightweight Apache HTTP server for your clients to download your mods and usermaps
  • Default cod4 configuration file server.cfg
    • Placed into /yourpath/main
    • Launched by default when not using mods with exec server.cfg
    • Easily changeable

Installation

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

  1. On your host, create the following directories:
    • /yourpath/main
    • /yourpath/zone
    • /yourpath/mods
    • /yourpath/usermaps
  2. From your Call of Duty 4 installation directory:
    1. Copy all the .iwd files from /mycod4path/main to /yourpath/main
    2. Copy all the files from /mycod4path/zone to /yourpath/zone
    3. (Optional) Copy the mods you want to use from /mycod4path/mods to /yourpath/mods
    4. (Optional) Copy the maps you want to use from /mycod4path/usermaps to /yourpath/usermaps

Option 1 of 2: Using Docker Compose

  1. Download docker-compose.yml

  2. Edit docker-compose.yml and replace:

    • /yourpath with your actual host path
    • (Optional) the value of ARGS with the argument you want (i.e. to use mods)
    • (Optional) the port mappings of each of the 2 containers
  3. To allow clients to download your mod and/or custom maps:

    1. Locate the relevant 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. You will have to setup port forwarding on your router. Ask me if you need help or Google.

  4. Launch the two containers in the background with:

    docker-compose up -d

Option 2 of 2: Using Docker only

Cod4x Server

In a terminal, enter (make sure to change paths):

docker run -d --name=cod4 --restart=always -p 28960:28960/udp \
    -v /yourpath/main:/cod4/main -v /yourpath/zone:/cod4/zone \
    -v /yourpath/mods:/cod4/mods -v /yourpath/usermaps:/cod4/usermaps \
    -e 'ARGS=+map mp_shipment' qmcgaw/cod4
  • The container UDP port 28960 is forwarded to the host UDP port 28960
  • The environment variable ARGS is optional and defaults to +set dedicated 2+set sv_cheats "1"+set sv_maxclients "64"+exec server.cfg+map_rotate

Apache HTTP server (Optional)

To allow clients to download your mod and/or custom maps

  1. Launch a lightweight HTTP server container with:

    docker run -d --name=cod4-http -p 8000:80/tcp --restart=always \
    -v /yourpath/mods:/usr/local/apache2/htdocs/mods \
    -v /yourpath/usermaps:/usr/local/apache2/htdocs/usermaps httpd:alpine

    Note that you can change the 8000 port to any port you like.

  2. Locate the relevant configuration file - for example main/server.cfg or mods/mymod/server.cfg

  3. 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"
  4. You will have to setup port forwarding on your router. Ask me if you need help or Google.

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 the cod4x_client.zip to your COD4 game directory
  4. Double click on install.cmd that you just extracted
  5. When launching the multiplayer game, you should see at the bottom right:

Bottom right screen cod4x

Testing

  1. Make sure you updated your COD4 Game to 1.8
  2. Launch the COD4 multiplayer game (iw3mp.exe)
  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 in /yourpath/mods/
  • Your main mod configuration file is server.cfg in /yourpath/mods/mymod/

Set the environment variable ARGS 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 ARGS environment variable:

  • +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

To do eventually

Acknowledgements

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

About

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