Call of Duty 4 Dedicated Server based on COD4x 1.7a as Docker image
It is based on:
- COD4 Client game version 1.7
- Original COD4 main and zone files required (from the client installation directory)
- Cod4x server features
- Works with custom mods and maps (see the Mods section)
- Easily configurable with docker-compose
- Runs without root (safer)
- Default cod4 configuration file server.cfg
- Placed into
./main
- Launched by default when not using mods with
exec server.cfg
- Easily changeable
- Placed into
We assume your call of duty 4 game is installed at /mycod4path
-
On your host, create the directories
./main
,./zone
,./mods
and./usermaps
. -
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
- Copy all the
-
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 zone usermaps
You can also run the container with
--user="root"
(unadvised!) -
Run the following command as root user on your host:
docker run -d --name=cod4 -p 28960:28960/udp -p 28960:28960/tcp \ -v $(pwd)/main:/home/user/cod4/main \ -v $(pwd)/zone:/home/user/cod4/zone:ro \ -v $(pwd)/mods:/home/user/cod4/mods \ -v $(pwd)/usermaps:/home/user/cod4/usermaps:ro \ -e CHECK_PORT=28960 \ -e CHECK_IP=127.0.0.1 \ freekers/docker-cod4x17a +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
There are two types of restarts:
-
If the container would stop for some reason (e.g. ShutdownGame) - Docker will restart it automatically ('restart' part in docker-compose.yml)
-
If for some reason the container would still run, but the
healthcheck
fails (e.g. the CoD4 server process is fronzen), the Docker container will be marked as 'unhealthy'. However, in this case, the container wouldn't be restarted automatically by Docker. For this you need an additional Docker image calledautoheal
. Here's a docker-compose.yml example for autoheal:
version: '3.7'
services:
autoheal:
image: willfarrell/autoheal
container_name: autoheal
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
AUTOHEAL_CONTAINER_LABEL: "all"
AUTOHEAL_CONTAINER_LABEL with value "all" means that all unhealthy containers would be restarted.
If you change the default server port, i.e. 28960, then make sure the CHECK_PORT
in your Docker run command or docker-compose matches your net_port
.
If you change net_ip
, then make sure the CHECK_IP
in your Docker run command or docker-compose matches your net_ip
.
- Launch the COD4 multiplayer game
- Click on Join Game
- Click on Source at the top until it's set on Favourites
- Click on New Favourite on the top right
- 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
)
- Add the port if you run it on something else than port UDP 28960 (i.e.
- Click on Refresh and try to connect to the server in the list
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
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, requireshost
network mode+set net_port 28961
don't use if not needed, requireshost
network mode+map_rotate
OR i.e.+map mp_shipment
should be the last launch argument
In order for the server to show up on the Activision Masterlist, you need to use host
network mode for the container so that it can bind to the WAN/Internet IP address of your server. Additionally, you need to set +set net_ip 123.123.123.123 +set net_port 28961
as ARGS
environment variable.
If using bridge
network mode, the container will bind to the IP address of the Docker network and therefore won't show up on the Activision Masterlist, as the heartbeat will send a 'local' IP-address to the Masterserver (e.g. 172.16.X.X.).
Note: This version of COD4x (1.7a) is no longer compatible with the COD4x Masterserver as it now requires a token to be listed, which has not been implemented/backported to COD4x version 1.7a.
- Credits to the developers of Cod4x server
- Forked from qdm12/cod4-docker