Skip to Content
Server OpsDocker (FXServer)

How to Run a FiveM Server Using Docker

You can host a FiveM server (FXServer) with Docker without installing FXServer directly on your Linux host. Docker Compose manages the container, while txAdmin handles the initial setup, server configuration, and restarts.

This guide starts with a working Docker Compose configuration, then covers connecting players, securing txAdmin, and keeping your server data safe.

Before you begin

You need:

  • A 64-bit x86 Linux machine or VPS with SSH access. Start with around 2 vCPUs and 4 GB RAM for a small test server; actual requirements depend on the number of players and resources.
  • Docker Engine  and the Docker Compose plugin .
  • A Cfx.re account  for txAdmin login and the server registration key.
  • Permission to open 30120/TCP and 30120/UDP in the host and provider firewalls. Port 40120/TCP is for the txAdmin web panel and will stay private in this example.

Image choice: The example uses traskin/fxserver, a third-party Docker image built from Cfx.re FXServer artifacts, not an official Cfx.re image. Review the image source  and test updates before using it for a production community. The example uses its recommended tag, which tracks the Cfx.re recommended artifact channel.

This setup targets Linux/amd64. On an ARM machine, such as an Apple Silicon Mac, an amd64 container may require emulation and is not recommended for a production FiveM host.

1. Verify Docker and create a project folder

On the machine that will host the server, run:

docker --version docker compose version mkdir -p ~/fivem-docker/txData chmod 700 ~/fivem-docker/txData cd ~/fivem-docker

Both version commands should succeed. If they do not, install Docker Engine and the Compose plugin before continuing.

2. Create the Docker Compose configuration

Create ~/fivem-docker/compose.yaml:

services: fxserver: image: traskin/fxserver:recommended restart: unless-stopped ports: - "30120:30120/tcp" - "30120:30120/udp" - "127.0.0.1:40120:40120/tcp" volumes: - ./txData:/txData

What each setting does:

SettingPurpose
imageUses the image’s recommended FXServer artifact channel.
restartRestarts the container after a crash or host reboot, unless you stopped it.
30120/tcp and 30120/udpPublishes the FiveM game server to players.
127.0.0.1:40120Makes txAdmin reachable only from the Docker host, not directly from the internet.
./txData:/txDataPersists txAdmin profiles, server configuration, and recipe-deployed data outside the container.

Do not put a registration key in compose.yaml. The txAdmin setup wizard will ask for it. Treat the contents of txData as sensitive: they can contain credentials and server configuration. Do not commit this directory to Git.

Check your Compose syntax before starting:

docker compose config

3. Start FXServer and read the txAdmin PIN

docker compose pull docker compose up -d docker compose ps docker compose logs --tail=100 -f fxserver

Look for the txAdmin URL and one-time PIN in the container logs. Press Ctrl+C to stop following the logs; the container continues running.

The image launches FXServer without +exec server.cfg, which starts the built-in txAdmin setup flow. You do not have to install txAdmin separately.

4. Open txAdmin securely

On the Docker host itself, open:

http://127.0.0.1:40120

If the Docker host is a remote VPS, create an SSH tunnel from your own computer instead:

ssh -L 40120:127.0.0.1:40120 ubuntu@YOUR_SERVER_IP

Replace ubuntu and YOUR_SERVER_IP with your SSH user and public server address. Leave the SSH session open and visit http://127.0.0.1:40120 in your local browser.

This avoids exposing txAdmin’s administrative login port to the public internet. Do not add a public firewall rule for port 40120.

Complete the txAdmin wizard:

  1. Enter the PIN shown in docker compose logs fxserver.
  2. Link your Cfx.re account and create the txAdmin backup password.
  3. Give the server a name and select Popular Recipes.
  4. Choose FiveM Basic Server (CFX Default) and keep the deployment data inside the persistent /txData mount.
  5. Generate a key in the Cfx.re Portal , enter it in the Recipe Deployer, and select Run Recipe.
  6. When deployment finishes, select Save & Run Server.

For screenshots and an explanation of each wizard screen, see txAdmin First Run or the official Cfx.re txAdmin setup guide .

A basic CFX recipe does not require MySQL. Frameworks such as QBCore or ESX may require a separate database; see Database Setup.

5. Allow players to connect

Allow game traffic through your VPS firewall/security group and, if applicable, your Linux firewall:

sudo ufw allow 30120/tcp sudo ufw allow 30120/udp sudo ufw status

If UFW is not enabled, follow your host’s firewall procedure. Before enabling UFW, make sure your SSH port is allowed so you do not lock yourself out. Home networks may also require router port forwarding to the Docker host.

Once txAdmin reports that the server is running:

  1. Open FiveM on your gaming PC.
  2. Press F8 to open the FiveM console.
  3. Enter connect YOUR_SERVER_IP:30120.

For local testing, use the host’s reachable local IP address instead. For additional port and connection checks, see Server Networking.

6. Manage, back up, and update the server

Run these commands from ~/fivem-docker:

# View recent output docker compose logs --tail=100 fxserver # Restart the container docker compose restart fxserver # Stop and start the container docker compose stop fxserver docker compose start fxserver

Back up the persistent data before updating (and back up any external database separately):

docker compose stop fxserver umask 077 tar -czf "fivem-backup-$(date +%F).tar.gz" txData docker compose up -d

Store a copy of that archive off the server, with restricted access. The bind mount means ordinary container replacement does not remove ./txData, but deleting that directory will remove your saved data.

To update to the current image for the selected channel:

docker compose pull fxserver docker compose up -d fxserver docker compose logs --tail=100 fxserver

For a production server, consider replacing :recommended with a tested, specific numeric image tag or immutable digest. Rolling tags can change between deployments. Keep the previous image reference and backup available for rollback.

Troubleshooting

ProblemWhat to check
txAdmin does not openCheck docker compose ps and docker compose logs fxserver. On a VPS, verify that the SSH tunnel is still connected.
Players cannot connectConfirm txAdmin started the game server and that both TCP and UDP port 30120 are allowed through Docker, the VPS firewall, and any router.
Server registration failsUse a valid key from the Cfx.re Portal and check FXServer logs. Do not publish your key in a repository or support post.
txAdmin asks to set up againVerify that ./txData is still mounted at /txData and that its files are intact.
Permission denied while saving filesInspect ownership and permissions of ./txData on the host. Fix the specific access problem; do not use chmod -R 777.
Server worked before an image updateReview logs, check the required artifact version, and restore the last tested image and backup if necessary.

Docker only manages the server process. You still need a current FXServer build, a valid registration key, compatible resources, backups, and sensible security settings.

Further reading