Docker Containers For IW4x (Linux)

The next IW4x update will include two features specifically designed for those hosting servers on Linux: native Fail2Ban integration, which I discussed in detail in a previous post, and support for “containerization.”

While Docker containers for IW4x were already possible, most were set up in a way that required brand-new game files and IW4x files for each container, making hosting more than one server infeasible.

The next update will allow server hosters to set up servers in such a way that the base game files and the IW4x will be completely separate in different folders on your system.

The “base game files” encompass every file downloadable from Steam when you install Modern Warfare® 2 (2011).

The “IW4x files” encompass every file from the iw4x-rawfiles and other client-specific files like the iw4x.dll

If you wish to set up a Docker container, consider the following configuration:

The folder where the docker will run will contain iw4x-rawfiles and iw4x.dll. Essentially, it holds all IW4x-specific files.

On the other hand, the /base_files (which could be anywhere on your system) folder will contain all Modern Warfare® 2 (2009) game files downloaded from Steam.

The advantage of this setup can only be fully leveraged if you set the /base_files folder to be read-only, allowing the IW4x server instance to access it without modifying it. Naturally, the server needs to write access to the container for tasks such as writing logs, updating the node file, storing Fail2Ban logs, etc.

Note: The AWOG community is already making use of this experimental feature and has moved all of their IW4x servers to Docker. They use Pterodactyl®, a free, open-source game server management panel. This panel orchestrates “Eggs” which are Docker containers.

1 Like

To utilize this feature, there are a few extra steps that a server hoster needs to take.

Before starting the IW4x server, you must update the DLL search paths so that iw4x.exe can locate all the DLLs from the /base_files and the iw4x.dll from the container.

The container will be the working directory of the iw4x.exe process, it will find iw4x.dll. However, it won’t be able to locate binkw32.dll and mss32.dll.

If you use wine to run the server, you may consider using it to emulate cmd.exe behaviour on Linux.

In your start batch file, add:

set PATH=Z:\base_files;%PATH%

If you use a Linux shell script, please refer to Google to determine the command needed to complete this step. I was only able to test it with cmd.exe.

Another crucial step is setting an environment variable that tells iw4x.exe where to find the base game files.

Before starting your server, export an environment variable BASE_FILES which will hold the location of the base game files.

If you use a batch file, add:

set BASE_FILES=Z:\base_files

Or, if you use a shell script, add:

export BASE_FILES=/base_files

With these two steps, your server should have no trouble finding the required game files.

Finally, you need to allocate a virtual frame for the IW4x process to “draw” windows, even though you won’t actually be using those in a headless environment.

Known issues:

  • You can’t type commands in the terminal once the server has started. Control your server using RCon in conjunction with the IW4M server management tool.

I would like to clarify the following: While it’s true that the old IW4x Docker containers, easily found on GitHub, are not ideal, they can provide you with the knowledge needed to build your own Dockerfile. The ideal Dockerfile only requires one folder containing the base game files for all your servers, ensuring that each instance of IW4x runs in its own container.

This can be done very simply from a shell script as well, WINEPATH=/base_files is all that is needed. Wine will append whatever is in WINEPATH to the “Windows” PATH variable.