Skip to main content
  • Instant digital delivery
  • Lifetime updates on selected products
  • Trusted by server owners
FiveMX
Shop
Full ServersBundlesNew releases
FiveMX

Start building your server today.

Curated FiveM resources, instant delivery, free starter mods, and practical guides in one calm marketplace.

Browse the shopsupport@fivemx.com

Shop

  • Shop
  • FiveM Mods
  • All Products
  • Free Mods
  • Best Scripts & Mods
  • FiveM Scripts

Frameworks

  • QBCore Scripts
  • ESX Scripts
  • QBox
  • Standalone

Community

  • Blog
  • Support
  • Creators
  • Affiliate

Legal

  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Digital Delivery
  • Cookie Policy
  • GDPR Compliance
  • DMCA
  • Imprint
  • Editorial Policy

Server Templates

  • QBCore Server Template
  • ESX Server Template
  • NoPixel Server Template
  • Server Packs
  • Free Server Templates
  • Tebex Alternative
Β© 2026 FiveMX. All rights reserved.Β·FiveMX is not affiliated with Rockstar Games, Take-Two Interactive, or CFX.re. All trademarks are property of their respective owners.
DiscordDocs
  1. Home
  2. Blog
  3. Tutorials & Guides
Table of Contents
PrerequisitesProject StructureThe DockerfileDocker Compose ConfigurationServer ConfigurationStarting the ServertxAdmin Setup Inside DockerAdding Resources and ScriptsPersistent Storage and BackupsUpdating the FiveM ServerRunning Multiple ServersDatabase IntegrationProduction HardeningFirewall RulesHealth ChecksResource MonitoringTroubleshooting Common IssuesNext Steps

How to Run a FiveM Server Using Docker: Complete Setup Guide

Published on April 1, 2026Β·by Lars Miller(Founder & Lead Editor)Β·CredentialsΒ·6 min read
Tutorials & Guidesfivem server docker

~100-200 MB RAM

Container overhead

A realistic planning buffer on top of your normal FiveM server footprint.

4-8 GB RAM

32-slot baseline

Typical allocation range for moderate script stacks with txAdmin and persistent volumes.

40120/TCP

Recommended txAdmin port

Keep it exposed separately so first-run setup and recovery stay straightforward.

Running a FiveM server inside Docker gives you environment consistency, simplified backups, reproducible deployments, and the ability to run multiple isolated server instances on…

Share
How to Run a FiveM Server Using Docker: Complete Setup Guide
How to Run a FiveM Server Using Docker: Complete Setup Guide

Running a FiveM server inside Docker gives you environment consistency, simplified backups, reproducible deployments, and the ability to run multiple isolated server instances on a single host. If you have ever spent hours debugging a server that works on one machine but not another, Docker eliminates that problem entirely.

This guide walks you through the complete process: from creating your Dockerfile to running a production-ready FiveM server with docker-compose, persistent storage, txAdmin, and proper resource management.

Prerequisites

FiveM Roleplay Server Guide and Scripts

Before starting, make sure you have:

  • A Linux VPS or dedicated server (Ubuntu 22.04+ or Debian 12+ recommended)
  • Docker Engine 24+ and Docker Compose v2 installed
  • A Cfx.re account with a valid server license key
  • Basic familiarity with the Linux command line

If Docker is not installed yet, the official installation takes less than a minute:

curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER

Log out and back in for the group change to take effect. Verify with docker --version and docker compose version.

Project Structure

Organize your FiveM Docker setup with a clean directory structure. This separation keeps your configuration, resources, and data manageable:

fivem-server/
β”œβ”€β”€ docker-compose.yml       # Container orchestration
β”œβ”€β”€ Dockerfile               # Server image definition
β”œβ”€β”€ server-data/
β”‚   β”œβ”€β”€ server.cfg           # FiveM server configuration
β”‚   └── resources/           # Your scripts and assets
β”‚       β”œβ”€β”€ [system]/
β”‚       β”œβ”€β”€ [gameplay]/
β”‚       └── [maps]/
β”œβ”€β”€ txData/                  # txAdmin persistent data
└── backups/                 # Automated backup target

Frequently Asked Questions

Can I run txAdmin inside the Docker container?

Yes. txAdmin is bundled with the FiveM server artifacts. Expose port 40120 in your docker-compose.yml and access the txAdmin web panel at http://your-server-ip:40120. The initial setup wizard runs on first launch. Mount your txAdmin data directory as a volume to persist configuration across container restarts.

How much RAM does a Dockerized FiveM server need?

Plan for the same resources as a bare-metal install plus roughly 100-200 MB overhead for the container runtime. A 32-slot server with moderate scripts needs 4-8 GB RAM allocated to Docker. Set memory limits in docker-compose.yml with deploy.resources.limits.memory to prevent the container from consuming all host RAM.

Can I run multiple FiveM servers on one host using Docker?

Absolutely β€” this is one of Docker's biggest advantages for FiveM hosting. Each server runs in its own container with isolated ports, resources, and configurations. Use different host port mappings (e.g., 30120, 30121, 30122) and separate volume mounts for each server instance. Docker Compose makes managing multiple servers straightforward.

Will Docker add noticeable latency for players?

No. Docker uses the host's network stack directly (especially with network_mode: host) and adds negligible overhead. The containerization layer operates at the OS level, not through virtualization. Players will not notice any difference compared to a bare-metal installation. CPU-bound operations like script execution perform identically.

Table of Contents

PrerequisitesProject StructureThe DockerfileDocker Compose ConfigurationServer ConfigurationStarting the ServertxAdmin Setup Inside DockerAdding Resources and ScriptsPersistent Storage and BackupsUpdating the FiveM ServerRunning Multiple ServersDatabase IntegrationProduction HardeningFirewall RulesHealth ChecksResource MonitoringTroubleshooting Common IssuesNext Steps

More on This Topic

Turn framework research into a launch-ready script stack

Use this guide to narrow the framework decision, then move into the core commercial hubs for verified scripts, curated bundles, and a faster server launch path.

QBCore starter

Use a complete QBCore base when the guide points to a new server launch and you want jobs, economy, UI, and admin tooling already connected.

View QBCore template

ESX starter

Compare a full ESX server pack when you need a faster path from setup research to a working roleplay stack.

View ESX server pack

Complete server path

If the article is part of a launch plan, start with full server packs that reduce setup time and connect multiple systems faster.

Open full server packs

Disclosure: Some links below are affiliate links to FiveMX products. We may earn a commission at no extra cost to you.

Free Scripts You Might Like

Related Articles

Running a FiveM server is not a simple task. You're managing game logic, player connections, database integrity, voice systems, and community dynamics all at once.

February 22, 2026

To set up a FiveM GTA RP server in 2026, install txAdmin on a Windows or Linux machine with at least 8 GB of RAM, let it download the FXServer artifacts automatically, create an…

January 29, 2026

Running a FiveM server allows you to create a customized multiplayer experience for Grand Theft Auto V. However, like any server software, you may...

October 27, 2024

Create the base structure:

mkdir -p fivem-server/{server-data/resources,txData,backups}
cd fivem-server

The Dockerfile

The Dockerfile builds a minimal image that downloads the latest FiveM server artifacts and sets up the runtime environment:

FROM debian:12-slim

ARG FIVEM_VERSION=latest

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        ca-certificates \
        curl \
        xz-utils \
        libatomic1 \
    && rm -rf /var/lib/apt/lists/*

RUN mkdir -p /opt/fivem /txData

# Download and extract FiveM server artifacts
RUN DOWNLOAD_URL=$(curl -s "https://changelogs-live.fivem.net/api/changelog/versions/linux/server" \
    | grep -oP '"latest":"[^"]*"' | head -1 | grep -oP 'https[^"]*') \
    && curl -Lo /tmp/fx-server.tar.xz "$DOWNLOAD_URL" \
    && tar -xf /tmp/fx-server.tar.xz -C /opt/fivem --strip-components=1 \
    && rm /tmp/fx-server.tar.xz

WORKDIR /opt/fivem

# FiveM game port (UDP + TCP)
EXPOSE 30120/tcp
EXPOSE 30120/udp

# txAdmin web interface
EXPOSE 40120/tcp

ENTRYPOINT ["/opt/fivem/run.sh"]
CMD ["+exec", "/server-data/server.cfg"]

Build the image:

docker build -t fivem-server:latest .

The image weighs approximately 200-300 MB β€” significantly smaller than a full Ubuntu install with the same dependencies.

Docker Compose Configuration

Docker Compose defines how your container runs, including port mappings, volume mounts, resource limits, and restart behavior. This is where the operational advantages of Docker become tangible.

Create docker-compose.yml:

services:
  fivem:
    build: .
    image: fivem-server:latest
    container_name: fivem-server
    restart: unless-stopped
    stdin_open: true
    tty: true

    ports:
      - "30120:30120/tcp"
      - "30120:30120/udp"
      - "40120:40120/tcp"  # txAdmin

    volumes:
      - ./server-data:/server-data
      - ./txData:/txData

    environment:
      - TXADMIN_PORT=40120

    deploy:
      resources:
        limits:
          memory: 8G
        reservations:
          memory: 4G

    logging:
      driver: json-file
      options:
        max-size: "50m"
        max-file: "5"

Key decisions in this configuration:

  • restart: unless-stopped ensures the server comes back after crashes or host reboots without restarting containers you intentionally stopped.
  • Volume mounts keep your server data and txAdmin configuration outside the container. Rebuilding or updating the image never touches your data.
  • Memory limits prevent a resource leak or poorly written script from consuming all host RAM and crashing other services.
  • Log rotation prevents Docker logs from filling your disk over time β€” a common issue on long-running game servers.

Server Configuration

Create your server-data/server.cfg with the essential directives:

# Server Identity
sv_hostname "My Docker FiveM Server"
sv_projectName "My Server"
sv_projectDesc "A containerized FiveM server"
sets sv_projectName "My Server"

# License and Authentication
sv_licenseKey "your-license-key-here"
sv_maxclients 32

# Network
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"

# Security
sv_scriptHookAllowed 0
set steam_webApiKey ""

# txAdmin
set txAdminPort 40120

# Resources
ensure mapmanager
ensure spawnmanager
ensure sessionmanager
ensure basic-gamemode
ensure hardcap
ensure chat
ensure monitor

Replace your-license-key-here with your actual Cfx.re license key. You can generate one at keymaster.fivem.net.

Starting the Server

Launch the server with a single command:

docker compose up -d

Monitor the startup process:

docker compose logs -f fivem

You should see the FiveM server initializing, loading resources, and eventually displaying the server startup message. txAdmin will be accessible at http://your-server-ip:40120 once the container is running.

To stop the server gracefully:

docker compose down

To restart after configuration changes:

docker compose restart fivem

txAdmin Setup Inside Docker

When you access http://your-server-ip:40120 for the first time, txAdmin walks you through the initial setup wizard:

  1. Create your txAdmin admin account (separate from your Cfx.re account)
  2. Link your Cfx.re account for license validation
  3. Select the server data path β€” point it to /server-data
  4. Choose your server template or point to your existing server.cfg

The txAdmin data directory (/txData) is mounted as a volume, so your admin accounts, player bans, scheduled restarts, and backups persist across container rebuilds.

Adding Resources and Scripts

Install scripts into your server-data/resources/ directory on the host machine. Changes are immediately visible inside the container because of the volume mount β€” no rebuild required.

# Example: Install a resource from GitHub
cd server-data/resources/
git clone https://github.com/example/my-resource.git

# Then add to server.cfg
echo 'ensure my-resource' >> ../server.cfg

Restart the server to load new resources:

docker compose restart fivem

For a curated collection of FiveM scripts and mods, browse our free mods library or the premium shop for production-ready resources with guaranteed compatibility.

Persistent Storage and Backups

Docker volumes ensure your data survives container restarts, updates, and rebuilds. The two critical directories are:

  • ./server-data: Your server configuration, resources, and any file-based data
  • ./txData: txAdmin configuration, player database, ban lists, and admin accounts

Automate backups with a simple cron job:

# Add to crontab (crontab -e)
0 4 * * * cd /path/to/fivem-server && tar -czf backups/backup-$(date +\%Y\%m\%d).tar.gz server-data/ txData/ --exclude='server-data/cache'

This creates a daily compressed backup at 4 AM, excluding the cache directory which can be regenerated. Rotate old backups to prevent disk fill:

# Keep last 14 days of backups
find /path/to/fivem-server/backups -name "backup-*.tar.gz" -mtime +14 -delete

Updating the FiveM Server

Updating a Dockerized FiveM server is clean and predictable. Your server data stays untouched β€” only the server artifacts change:

# Rebuild the image with latest artifacts
docker compose build --no-cache fivem

# Restart with the new image
docker compose up -d fivem

If something breaks after an update, rolling back is instant:

# Tag your current working image before updating
docker tag fivem-server:latest fivem-server:backup

# If the update causes issues, revert
docker tag fivem-server:backup fivem-server:latest
docker compose up -d fivem

This rollback capability alone makes Docker worth the setup effort. On a bare-metal server, reverting a bad update means manually restoring files and hoping you didn't miss anything.

Running Multiple Servers

One of Docker's strongest advantages for FiveM hosting is running multiple isolated server instances on a single host. Each server gets its own container, ports, and data:

services:
  fivem-main:
    build: .
    container_name: fivem-main
    restart: unless-stopped
    ports:
      - "30120:30120/tcp"
      - "30120:30120/udp"
      - "40120:40120/tcp"
    volumes:
      - ./servers/main/server-data:/server-data
      - ./servers/main/txData:/txData
    deploy:
      resources:
        limits:
          memory: 8G

  fivem-test:
    build: .
    container_name: fivem-test
    restart: unless-stopped
    ports:
      - "30121:30120/tcp"
      - "30121:30120/udp"
      - "40121:40120/tcp"
    volumes:
      - ./servers/test/server-data:/server-data
      - ./servers/test/txData:/txData
    deploy:
      resources:
        limits:
          memory: 4G

Start both servers:

docker compose up -d

Each server is completely isolated. You can test scripts on the test server without risking your production environment.

Database Integration

Most FiveM servers need a MySQL or MariaDB database for frameworks like ESX, QBCore, or QBox. Add it to your docker-compose.yml:

services:
  fivem:
    build: .
    container_name: fivem-server
    restart: unless-stopped
    depends_on:
      - db
    ports:
      - "30120:30120/tcp"
      - "30120:30120/udp"
      - "40120:40120/tcp"
    volumes:
      - ./server-data:/server-data
      - ./txData:/txData
    deploy:
      resources:
        limits:
          memory: 8G

  db:
    image: mariadb:11
    container_name: fivem-db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: "change-this-strong-password"
      MYSQL_DATABASE: "fivem"
      MYSQL_USER: "fivem"
      MYSQL_PASSWORD: "change-this-too"
    ports:
      - "3306:3306"
    volumes:
      - db-data:/var/lib/mysql

volumes:
  db-data:

In your resource database configuration (e.g., oxmysql or mysql-async), use db as the hostname since Docker Compose creates an internal network where containers can reach each other by service name:

set mysql_connection_string "mysql://fivem:change-this-too@db:3306/fivem?charset=utf8mb4"

Production Hardening

Before exposing your Dockerized FiveM server to players, apply these production best practices:

Firewall Rules

Only expose the ports you actually need:

# Allow FiveM game traffic
sudo ufw allow 30120/tcp
sudo ufw allow 30120/udp

# Allow txAdmin (restrict to your IP if possible)
sudo ufw allow from YOUR_IP to any port 40120

# Block everything else
sudo ufw enable

Health Checks

Add a health check to your docker-compose.yml so Docker can detect and restart a stuck server:

services:
  fivem:
    # ... other config
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:30120/info.json"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s

Resource Monitoring

Monitor your container's resource usage:

# Real-time stats
docker stats fivem-server

# Detailed inspection
docker inspect fivem-server --format='{{.State.Status}} - Memory: {{.HostConfig.Memory}}'

Set up alerts when memory or CPU usage exceeds thresholds to catch problems before players notice them.

Troubleshooting Common Issues

Container exits immediately after starting: Check the logs with docker compose logs fivem. Common causes: invalid license key, missing server.cfg, or port conflicts. Verify your license key is correct and no other process is using port 30120.

Cannot connect to the server: Ensure ports 30120/tcp and 30120/udp are open in your firewall and correctly mapped in docker-compose.yml. Test with docker compose port fivem 30120 to verify the mapping.

txAdmin not accessible: Verify port 40120 is exposed and not blocked by a firewall. Check that the TXADMIN_PORT environment variable matches the exposed port.

Resources not loading after adding them: Volume mounts sync automatically, but FiveM needs a restart to detect new resources. Run docker compose restart fivem and ensure the resource is listed in server.cfg with ensure.

Database connection refused: If using Docker Compose networking, use the service name (e.g., db) as the hostname, not localhost or 127.0.0.1. The database container must be running and healthy before FiveM starts β€” depends_on handles startup order.

For deeper debugging techniques, check our guide on how to debug your FiveM server.

Next Steps

With your FiveM server running in Docker, you have a solid foundation for scaling and maintaining your community. Here are the logical next steps:

  • Optimize performance with our FiveM server optimization guide β€” profiling, script cleanup, and network tuning
  • Set up txAdmin with Discord using our txAdmin Discord integration guide for remote server management
  • Browse production-ready scripts in our free mods library or premium shop β€” all tested and maintained
  • Scale your community with strategies from our complete server management guide

Docker transforms FiveM server management from manual sysadmin work into reproducible, version-controlled infrastructure. Every configuration change is tracked, every update is reversible, and every backup is predictable. That operational discipline is what separates servers that last from servers that burn out.

Launch faster

Compare curated bundles

Bundles shorten the path from planning to launch by grouping the highest-leverage scripts into a cleaner commercial starting point.

View bundles
Previous Article

FiveM on Steam and the alt:V Shutdown: What Server Owners Need to Know

Next Article

FiveM Full Server Download: Complete Server Packs Explained (2026)

Ultimate Drift Server Guide: Top Cars, Mods & Setups for FiveM
Which FiveM Server Pack Fits Your Roleplay Community?
Top 5 FiveM Server Templates 2026 β€” Ready-to-Go Server Packs
How to Make a FiveM Server for Free in 2026 β€” Honest Guide
How to Install a FiveM Server Template (2026) β€” Step-by-Step Guide
Start from a QBCore full server
Review the Super ESX Server pack
Compare full server packs
Gameconfig for Legacy & Enhanced

Gameconfig for Legacy & Enhanced

8,243,364 downloads
PC Trainer V

PC Trainer V

1,272,946 downloads
LemonUI: Open Source UI Library

LemonUI: Open Source UI Library

1,138,096 downloads
NFS gauge - RPM Gear Speedometer & Timer

NFS gauge - RPM Gear Speedometer & Timer

1,058,515 downloads
FiveM Server Management: The Complete Guide from Setup to Scale
FiveM Server Management: The Complete Guide from Setup to Scale
How to Set Up a FiveM GTA RP Server (2026) β€” Complete Step-by-Step Guide
How to Set Up a FiveM GTA RP Server (2026) β€” Complete Step-by-Step Guide
How to debug your FiveM server
How to debug your FiveM server

No time to configure everything yourself?

Start with a pre-built, tested FiveM server pack. Framework-optimized, all scripts pre-installed.

Super ESX Server
esxstandalone

Super ESX Server

The Super ESX Server is one of the best FiveM server templates - over 1.000 purchases! Want to know why we call it our Super Server? Check out our video to find out some of the basics details of the world. Update 10 is included, make sure to install v7 first and then use content of v10 yo

$228.32
ESX Server Base (by RibSosay)
esxstandalone

ESX Server Base (by RibSosay)

Prebuilt FiveM server with ESX framework GUARANTEE : We offer a guarantee ensuring compatibility with your setup.

$53.99
View all server packs