Getting started
4. Configure your ports
5min
when spinning up containers on a machine, our orchestrator has to decide upfront which networking modes it puts a container in this affects how external clients (your players) will connect to the game server application running inside the container the docker engine has two built in networking modes as gameye is a layer on top of the docker engine, our orchestrator can use them both and decide which is best according to your needs using bridge networking learn more about bridge networking for a more in depth description of bridge networking, check docker’s website bridge networking lets multiple containers bind to any port without clogging up the networking stack of the host machine for example, you have 10 different nginx containers and they should all bind to port 8080 how does traffic flow to these nginx instances? the bridge network opens up an ephemeral port and links it to port 8080 of a specific container as docker keeps track of these networks and containers, it can easily forward all traffic when we create a new container, our orchestrator automatically allocates an ephemeral port (between 32768 and 60299 ) as the orchestrator knows all the containers (and where they’re running), it searches for an available port in ascending order if you use bridge networking, your dockerfile from step three will stay the same using host networking learn more about host networking for a more in depth description of host networking, check docker’s website host networking is where you keep reusing the networking stack of the host machine when a container needs to reserve a specific port (like 8080 ), it’ll block any other container from using that port that means only one container on the whole machine uses port 8080 that can obviously clog up the ports so to prevent that, our orchestrator needs to allocate an ephemeral port to use instead (between 32768 and 60299 ) as the orchestrator knows all the containers (and where they’re running), it searches for an available port in ascending order once we’ve chosen the port, we add it as an environment variable (like gameye port tcp 8080 ) the container then has access to the port it can then bind or publish the port as metadata to matchmakers, clients or other services if you want to use host networking, there are a few tweaks you need to make to your dockerfile from step three and your entrypoint you can use the following code blocks to help you make those changes from ubuntu 20 04 \# copy server files here \# for example copy /home/mygame/ \# add user to run the container run useradd m gameuser \# set permissions run chmod 777 /home/mygame/gameserver sh user gameuser \# set your game binary as the entrypoint entrypoint \["/home/mygame/gameserver sh", " log"] \#!/bin/bash /gameserver x86 64 batchmode nographics start name "gameye server" overrideeditorargs sessionname $gameye session id port $gameye port udp 7777 log txt timeout 30 "$@" \# store server execution exit code status=$? if test $status eq 0 then echo "server exited normally" else echo "server exited with code $status" fi echo "done"