Container builds
Learn how to package your game server as a Docker container image for deployment.
Read time 3 minutesLast updated 3 days ago
A container is a way of packing software and all its dependencies together in a single unit. With Multiplay Hosting container builds, you can package your game servers and their dependencies, build a container, and push it to the Multiplay Hosting container registry.
You can create a container build through the Unity Dashboard by selecting Container image when you create a build. Refer to Create a build with a container image.
Multiplay Hosting uses Docker container tags in the format
<ImageName>:<ImageTag>docker tag <ImageName>:<ImageTag> registry.multiplay.com/4818982f-bb28-4c39-9d44-628204b6780e/1ae4de65-849d-4ff1-86fc-1de3bdfbd891/12788:v1
Container build requirements
When you create a Multiplay Hosting build, you have several options for uploading your build file. One option is to use Docker and the Multiplay Hosting container registry to upload a containerized version of your build. However, your build container must meet specific requirements (in addition to the general integration requirements) before you can use a containerized build.Create a container built with the base image
The linux-build-image template container takes care of most of the additional requirements of using a container build. You can use the container by addingFROM unitymultiplay/linux-base-image:<tag>In the preceding example:FROM unitymultiplay/linux-base-image:<tag># copy game files here# for example:WORKDIR /gameCOPY --chown=mpukgame . .# set your game binary as the entrypointENTRYPOINT [ "./gamebinary" ]
- Replace with the version of the base image to use. You can check the linux-base-image tags for a list of available tags.
<tag> - Set to the current working directory of the container process. Any actions to run processes or copy files are relative to the working directory.
WORKDIR - Set to the executable that runs when the container starts. This entrypoint should be your game server binary.
ENTRYPOINT
For a simple example, refer to this Simple Game Server Dockerfile (Unity Multiplay examples on GitHub).
Create a container build from scratch
If you prefer to create your Dockerfile from scratch, it’s your responsibility to ensure your container meets the following requirements.| Requirement | Description |
| Your container must use |
| Your container must have an |
# ======================================================== ## Unity base image stuff ## ======================================================== #FROM ubuntu:20.04 AS mpukRUN addgroup --gid 2000 mpukgame && \ useradd -g 2000 -u 2000 -ms /bin/sh mpukgame && \ mkdir /game && \ chown mpukgame:mpukgame /game && \ apt update && \ apt upgrade && \ apt install -y ca-certificatesUSER mpukgame# ======================================================== ## Custom game stuff ## ======================================================== #FROM mpuk AS game# copy game files here# for example:WORKDIR /gameCOPY --chown=mpukgame . .# set your game binary as the entrypointENTRYPOINT [ "./gamebinary" ]
Create a container build using server builds uploaded to Steam
To upload a container build for use with game server builds uploaded to Steam, it is possible to use SteamCMD to build your container image. The following code block is an example Dockerfile for the SteamCMD process:# ======================================================== ## SteamCMD stuff ## ======================================================== #FROM steamcmd/steamcmd:ubuntu-20 AS steamcmdWORKDIR /gameCOPY update.txt /data/update.txtRUN steamcmd +runscript /data/update.txt# if you want to avoid having the update.txt file, use:# RUN steamcmd +force_install_dir /game/<game_name> \# +login anonymous +app_update <steam_appid> validate +quit# ======================================================== ## Unity base image stuff ## ======================================================== #FROM ubuntu:20.04 AS mpukRUN addgroup --gid 2000 mpukgame && \ useradd -g 2000 -u 2000 -ms /bin/sh mpukgame && \ mkdir /game && \ chown mpukgame:mpukgame /game && \ apt update && \ apt upgrade && \ apt install -y ca-certificates lib32z1USER mpukgame# ======================================================== ## Custom game stuff ## ======================================================== #WORKDIR /gameCOPY --from=steamcmd --chown=mpukgame:mpukgame /game/<game_name> /game/<game_name># set your game binary as the entrypointENTRYPOINT [ "./game_binary" ]
Pulling a container build
For security reasons, pulling content from the registry is not permitted. If you require an offline copy of your build, make sure to also push the image to a registry you control for later use.Server.json file
If you use the base container image, theserver.jsonserver.json- For Linux containers, it's in the environment variable.
$HOME - For Windows containers, it's in the environment variable.
$HOMEPATH
server.jsonserver.json