Container builds
A container is a way of packing software and all its dependencies together in a single unit. Multiplay Hosting container builds allow you to 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 Cloud Dashboard by selecting Container image when you create a build. The Create build wizard walks you through adding a service account, adding the registry, and selecting an image. Refer to Create a build with a container image.
Multiplay Hosting uses Docker container tags in the format <ImageName>:<ImageTag>
. Multiplay Hosting generates the correct name and tag for your build, and displays it to you in the Unity Cloud Dashboard when you create or update a container build.
docker tag <ImageName>:<ImageTag> registry.multiplay.com/4818982f-bb28-4c39-9d44-628204b6780e/1ae4de65-849d-4ff1-86fc-1de3bdfbd891/12788:v1
Note: Multiplay Hosting only generates the ImageName
and ImageTag
for you when you create a build through the Unity Cloud Dashboard. If you use the CLI tool, you must create the ImageName
and ImageTag
.
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 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 adding FROM unitymultiplay/linux-base-image:<tag>
to the top of your Dockerfile, as the following code demonstrates.
For more information, refer to Dockerfile reference (Docker documentation).
FROM unitymultiplay/linux-base-image:<tag>
# copy game files here
# for example:
WORKDIR /game
COPY --chown=mpukgame . .
# set your game binary as the entrypoint
ENTRYPOINT [ "./gamebinary" ]
In the preceding example:
- Replace
<tag>
with the version of the base image to use. You can check the linux-base-image tags for a list of available tags. - Set
WORKDIR
to the current working directory of the container process. Any actions to run processes or copy files are relative to the working directory. - Set
ENTRYPOINT
to the executable that runs when the container starts. This entrypoint should be your game server binary.
Warning: Launch parameters specified in the build configuration can overwrite CMD
defined in the Dockerfile.
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.
Warning: Use the base image unless you have a specific or advanced uses in which you must create the container from scratch.
Requirement | Description |
USER mpukgame | Your container must use mpukgame as the USER . This user must have a group identifier (GID) of 2000 and a user identifier (UID) of 2000. |
ENTRYPOINT | Your container must have an ENTRYPOINT . |
The following code block is a simple Dockerfile that meets these requirements:
# ======================================================== #
# Unity base image stuff #
# ======================================================== #
FROM ubuntu:20.04 AS mpuk
RUN 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
USER mpukgame
# ======================================================== #
# Custom game stuff #
# ======================================================== #
FROM mpuk AS game
# copy game files here
# for example:
WORKDIR /game
COPY --chown=mpukgame . .
# set your game binary as the entrypoint
ENTRYPOINT [ "./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 steamcmd
WORKDIR /game
COPY update.txt /data/update.txt
RUN 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 mpuk
RUN 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 lib32z1
USER mpukgame
# ======================================================== #
# Custom game stuff #
# ======================================================== #
WORKDIR /game
COPY --from=steamcmd --chown=mpukgame:mpukgame /game/<game_name> /game/<game_name>
# set your game binary as the entrypoint
ENTRYPOINT [ "./game_binary" ]
Server.json file
If you use the base container image, the server.json
file is already mounted into your container. You can find the server.json
file location by checking the container's home environment variable.
- For Linux containers, it's in the
$HOME
environment variable. - For Windows containers, it's in the
$HOMEPATH
environment variable.
If you create a container build from scratch, create your own server.json
file and include it in the container image. Refer to Server.json for the format of this file, and Configuration variables for an explanation of server.json
's variables.