How to Run a FiveM Server Using Docker: Complete Setup Guide
~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…

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

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
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-stoppedensures 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:
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.

