Portainer Templates logo

Portainer Templates

Factorio Server

Stack

Game Servers

Headless Factorio via factoriotools/factorio - the community-standard image. Saves, mods, and server settings live on the /factorio volume; a new map generates on first boot and the latest save loads thereafter.

Image details

Pulls: 29.3M
Architecture: amd64, arm64
Image size: 214 MB
Latest: 2.0.77-rootless
User: factoriotools
Created: May 02, 2019
Updated: 2 days ago
Status: active

Configuration

Type
Compose
Platform
linux
Image
factoriotools/factorio:stable
Ports
34197:34197/udp
Volumes
/factorio : factoriodata
Env vars
LOAD_LATEST_SAVE=trueGENERATE_NEW_SAVE=trueSAVE_NAME=${SAVE_NAME:-miget}UPDATE_MODS_ON_START=${UPDATE_MODS_ON_START:-false}
Restart
unless-stopped
Source

Standalone Install

Select an install method, to see config/commands for deploying Factorio Server

Installation method

Install on Portainer

Import all app templates into your Portainer instance, for easy 1-click deploys

  1. Ensure both Docker and Portainer are installed, and up-to-date
  2. Log into your Portainer web UI
  3. Under Settings → App Templates, paste the below URL
  4. Head to Home → App Templates, and the list of apps will show up
  5. Select Factorio Server, fill in any config options, and hit Deploy

Template Import URL

https://raw.githubusercontent.com/Lissy93/portainer-templates/main/templates.json
Show Me demo
Original stackfile

The compose file this template deploys, straight from its repo:

name: factorio

services:
  factorio:
    image: factoriotools/factorio:stable
    restart: unless-stopped
    environment:
      LOAD_LATEST_SAVE: "true"
      GENERATE_NEW_SAVE: "true"
      SAVE_NAME: ${SAVE_NAME:-miget}
      UPDATE_MODS_ON_START: ${UPDATE_MODS_ON_START:-false}
    ports:
      - "34197:34197/udp"
    volumes:
      - factoriodata:/factorio

volumes:
  factoriodata:

Or deploy it directly from the source:

git clone https://github.com/deployable-sh/stacks
cd stacks
docker compose -f factorio/compose.yaml up -d

More install options in our documentation.

Factorio Docker Version Docker Pulls Docker Stars

!NOTE Support for ARM is experimental. Expect crashes and lag if you try to run this on a raspberry pi.

中文
  • latest, 2.0.76

Tag descriptions

What is Factorio?

Factorio is a game in which you build and maintain factories.
You will be mining resources, researching technologies, building infrastructure, automating production and fighting enemies. Use your imagination to design your factory, combine simple elements into ingenious structures, apply management skills to keep it working and finally protect it from the creatures who don't really like you.
The game is very stable and optimized for building massive factories. You can create your own maps, write mods in Lua or play with friends via Multiplayer.
NOTE: This is only the server. The full game is available at Factorio.com, Steam, GOG.com and Humble Bundle.

Usage

Quick Start

Run the server to create the necessary folder structure and configuration files. For this example data is stored in /opt/factorio.
sudo mkdir -p /opt/factorio
sudo chown 845:845 /opt/factorio
sudo docker run -d \
  -p 34197:34197/udp \
  -p 27015:27015/tcp \
  -v /opt/factorio:/factorio \
  --name factorio \
  --restart=unless-stopped \
  factoriotools/factorio

For those new to Docker, here is an explanation of the options:
  • -d - Run as a daemon ("detached").
  • -p - Expose ports.
  • -v - Mount /opt/factorio on the local file system to /factorio in the container.
  • --restart - Restart the server if it crashes and at system start
  • --name - Name the container "factorio" (otherwise it has a funny random name).

The chown command is needed because in 0.16+, we no longer run the game server as root for security reasons, but rather as a 'factorio' user with user id 845. The host must therefore allow these files to be written by that user.
Check the logs to see what happened:
docker logs factorio

Stop the server:
docker stop factorio

Now there's a server-settings.json file in the folder /opt/factorio/config. Modify this to your liking and restart the server:
docker start factorio

Try to connect to the server. Check the logs if it isn't working.

Console

To issue console commands to the server, start the server in interactive mode with -it. Open the console with docker attach and then type commands.
docker run -d -it  \
      --name factorio \
      factoriotools/factorio
docker attach factorio

RCON (2.0.18+)

Alternativly (e.g. for scripting) the RCON connection can be used to send commands to the running factorio server. This does not require the RCON connection to be exposed.
docker exec factorio rcon /h

Upgrading

Before upgrading backup the save. It's easy to make a save in the client.
Ensure -v was used to run the server so the save is outside of the Docker container. The docker rm command completely destroys the container, which includes the save if it isn't stored in a data volume.
Delete the container and refresh the image:
docker stop factorio
docker rm factorio
docker pull factoriotools/factorio

Now run the server as before. In about a minute the new version of Factorio should be up and running, complete with saves and config!

Saves

A new map named _autosave1.zip is generated the first time the server is started. The map-gen-settings.json and map-settings.json files in /opt/factorio/config are used for the map settings. On subsequent runs the newest save is used.
To load an old save stop the server and run the command touch oldsave.zip. This resets the date. Then restart the server. Another option is to delete all saves except one.
To generate a new map stop the server, delete all of the saves and restart the server.

Specify a save directly (0.17.79-2+)

You can specify a specific save to load by configuring the server through a set of environment variables:
To load an existing save set SAVE_NAME to the name of your existing save file located within the saves directory, without the .zip extension:
sudo docker run -d \
  -p 34197:34197/udp \
  -p 27015:27015/tcp \
  -v /opt/factorio:/factorio \
  -e LOAD_LATEST_SAVE=false \
  -e SAVE_NAME=replaceme \
  --name factorio \
  --restart=unless-stopped \
  factoriotools/factorio

To generate a new map set GENERATE_NEW_SAVE=true and specify SAVE_NAME:
sudo docker run -d \
  -p 34197:34197/udp \
  -p 27015:27015/tcp \
  -v /opt/factorio:/factorio \
  -e LOAD_LATEST_SAVE=false \
  -e GENERATE_NEW_SAVE=true \
  -e SAVE_NAME=replaceme \
  --name factorio \
  --restart=unless-stopped \
  factoriotools/factorio

To generate a new map with a specific preset (e.g., death-world):
sudo docker run -d \
  -p 34197:34197/udp \
  -p 27015:27015/tcp \
  -v /opt/factorio:/factorio \
  -e LOAD_LATEST_SAVE=false \
  -e GENERATE_NEW_SAVE=true \
  -e SAVE_NAME=replaceme \
  -e PRESET=death-world \
  --name factorio \
  --restart=unless-stopped \
  factoriotools/factorio

Mods

Copy mods into the mods folder and restart the server.
As of 0.17 a new environment variable was added `UPDATE_MODS_ON_START which if set to true` will cause the mods get to updated on server start. If set a valid Factorio Username and Token must be supplied or else the server will not start. They can either be set as docker secrets, environment variables, or pulled from the server-settings.json file.
To prevent specific mods from being automatically updated, you can use the `UPDATE_IGNORE environment variable with a comma-separated list of mod names. For example: UPDATE_IGNORE=mod1,mod2,mod3` will skip updates for those three mods. This can be useful to prevent compatibility issues when certain mods should remain at specific versions. Be warned that it can also create compatibility issues.
Note: When using the Space Age DLC, the built-in mods (elevated-rails, quality, and space-age) are automatically skipped during mod updates to prevent conflicts. These mods are included with the DLC and should not be downloaded separately.

Scenarios

If you want to launch a scenario from a clean start (not from a saved map) you'll need to start the docker image from an alternate entrypoint. To do this, use the example entrypoint file stored in the /factorio/entrypoints directory in the volume, and launch the image with the following syntax. Note that this is the normal syntax with the addition of the --entrypoint setting AND the additional argument at the end, which is the name of the Scenario in the Scenarios folder.
docker run -d \
  -p 34197:34197/udp \
  -p 27015:27015/tcp \
  -v /opt/factorio:/factorio \
  --name factorio \
  --restart=unless-stopped  \
  --entrypoint "/scenario.sh" \
  factoriotools/factorio \
  MyScenarioName

Converting Scenarios to Regular Maps

If you would like to export your scenario to a saved map, you can use the example entrypoint similar to the Scenario usage above. Factorio will run once, converting the Scenario to a saved Map in your saves directory. A restart of the docker image using the standard options will then load that map, just as if the scenario were just started by the Scenarios example noted above.
docker run -d \
  -p 34197:34197/udp \
  -p 27015:27015/tcp \
  -v /opt/factorio:/factorio \
  --name factorio \
  --restart=unless-stopped  \
  --entrypoint "/scenario2map.sh" \
  factoriotools/factorio
  MyScenarioName

RCON

Set the RCON password in the rconpw file. A random password is generated if rconpw doesn't exist.
To change the password, stop the server, modify rconpw, and restart the server.
To "disable" RCON don't expose port 27015, i.e. start the server without -p 27015:27015/tcp. RCON is still running, but nobody can to connect to it.

Whitelisting (0.15.3+)

Create file config/server-whitelist.json and add the whitelisted users.
[
"you",
"friend"
]

Banlisting (0.17.1+)

Create file config/server-banlist.json and add the banlisted users.
[
"bad_person",
"other_bad_person"
]

Adminlisting (0.17.1+)

Create file config/server-adminlist.json and add the adminlisted users.
[
"you",
"friend"
]

Customize configuration files (0.17.x+)

Out-of-the box, factorio does not support environment variables inside the configuration files. A workaround is the usage of envsubst which generates the configuration files dynamically during startup from environment variables set in docker-compose:
Example which replaces the server-settings.json:
factorio_1:
  image: factoriotools/factorio
  ports:
    - "34197:34197/udp"
  volumes:
   - /opt/factorio:/factorio
   - ./server-settings.json:/server-settings.json
  environment:
    - INSTANCE_NAME=Your Instance's Name
    - INSTANCE_DESC=Your Instance's Description
  entrypoint: /bin/sh -c "mkdir -p /factorio/config && envsubst < /server-settings.json > /factorio/config/server-settings.json && exec /docker-entrypoint.sh"

The server-settings.json file may then contain the variable references like this:
"name": "${INSTANCE_NAME}",
"description": "${INSTANCE_DESC}",

Environment Variables

These are the environment variables which can be specified at container run time.
Variable NameDescriptionDefaultAvailable in
GENERATENEWSAVEGenerate a new save if one does not exist before starting the serverfalse0.17+
LOADLATESTSAVELoad latest when true. Otherwise load SAVENAMEtrue0.17+
PORTUDP port the server listens on341970.15+
BINDIP address (v4 or v6) the server listens on (IP\[:PORT)0.15+
RCONPORTTCP port the rcon server listens on270150.15+
SAVENAMEName to use for the save fileautosave10.17+
PRESETMap generation preset when GENERATENEWSAVE is true0.17+
TOKENfactorio.com token0.17+
UPDATEMODSONSTARTIf mods should be updated before starting the server0.17+
UPDATEIGNOREComma-separated list of mod names to skip during automatic updates0.17+
USERNAMEfactorio.com username0.17+
CONSOLELOGLOCATIONSaves the console log to the specifies location
DLCSPACEAGEEnables or disables the mods for DLC Space Age in mod-list.json^1true2.0.8+
MODSMod directory to use/factorio/mods2.0.8+

Note: All environment variables are compared as strings

PRESET Values

The PRESET environment variable is used when generating a new map (when GENERATE_NEW_SAVE=true). It corresponds to Factorio's built-in map generation presets. Common values include:
  • default - Normal settings
  • rich-resources - Resources are more abundant
  • marathon - Recipes and technologies are more expensive
  • death-world - Biters are more aggressive and numerous
  • death-world-marathon - Combines death-world and marathon settings
  • rail-world - Resources are further apart, encouraging train usage
  • ribbon-world - Map height is limited for a unique challenge

If PRESET is not specified or left empty, the map will be generated using the settings from map-gen-settings.json and map-settings.json without a preset.

Container Details

The philosophy is to keep it simple.
  • The server should bootstrap itself.
  • Prefer configuration files over environment variables.
  • Use one volume for data.

Volumes

To keep things simple, the container uses a single volume mounted at /factorio. This volume stores configuration, mods, and saves.
The files in this volume should be owned by the factorio user, uid 845.
factorio
|-- config
|   |-- map-gen-settings.json
|   |-- map-settings.json
|   |-- rconpw
|   |-- server-adminlist.json
|   |-- server-banlist.json
|   |-- server-settings.json
|   `-- server-whitelist.json
|-- mods
|   `-- fancymod.zip
`-- saves
    `-- _autosave1.zip

Docker Compose

Docker Compose is an easy way to run Docker containers.
  • docker-engine >= 1.10.0 is required
  • docker-compose >=1.6.0 is required

First get a docker-compose.yml file. To get it from this repository:
git clone https://github.com/factoriotools/factorio-docker.git
cd factorio-docker/docker

Or make your own:
version: '2'
services:
  factorio:
    image: factoriotools/factorio
    ports:
     - "34197:34197/udp"
     - "27015:27015/tcp"
    volumes:
     - /opt/factorio:/factorio

Now cd to the directory with docker-compose.yml and run:
sudo mkdir -p /opt/factorio
sudo chown 845:845 /opt/factorio
sudo docker-compose up -d

Ports

  • 34197/udp - Game server (required). This can be changed with the PORT environment variable.
  • 27015/tcp - RCON (optional).

LAN Games

Ensure the lan setting in server-settings.json is true.
"visibility":
{
  "public": false,
  "lan": true
},

Start the container with the --network=host option so clients can automatically find LAN games. Refer to the Quick Start to create the /opt/factorio directory.
sudo docker run -d \
  --network=host \
  -p 34197:34197/udp \
  -p 27015:27015/tcp \
  -v /opt/factorio:/factorio \
  --name factorio \
  --restart=unless-stopped  \
  factoriotools/factorio

Deploy to other plaforms

Vagrant

Vagrant is a easy way to setup a virtual machine (VM) to run Docker. The Factorio Vagrant box repository contains a sample Vagrantfile.
For LAN games the VM needs an internal IP in order for clients to connect. One way to do this is with a public network. The VM uses DHCP to acquire an IP address. The VM must also forward port 34197.
config.vm.network "public_network"
config.vm.network "forwarded_port", guest: 34197, host: 34197

Amazon Web Services (AWS) Deployment

If you're looking for a simple way to deploy this to the Amazon Web Services Cloud, check out the Factorio Server Deployment (CloudFormation) repository. This repository contains a CloudFormation template that will get you up and running in AWS in a matter of minutes. Optionally it uses Spot Pricing so the server is very cheap, and you can easily turn it off when not in use.

Using a reverse proxy

If you need to use a reverse proxy you can use the following nginx snippet:
stream {
  server {
      listen 34197 udp reuseport;
      proxy_pass my.upstream.host:34197;
  }
}

If your factorio host uses multiple IP addresses (very common with IPv6), you might additionally need to bind Factorio to a single IP (otherwise the UDP proxy might get confused with IP mismatches). To do that pass the BIND envvar to the container: docker run --network=host -e BIND=2a02:1234::5678 ...

Rootless Docker Support (Experimental)

Note: Rootless support is currently experimental. Please report any issues you encounter.

If you're experiencing permission issues or want better security, consider using the rootless images. These images are designed to work seamlessly with rootless Docker installations and avoid common permission problems.

What are Rootless Images?

The rootless images differ from regular images in several ways:
  • Run as UID 1000 (non-root) by default
  • No dynamic UID/GID mapping (PUID/PGID not supported)
  • No runtime chown operations
  • All directories created with open permissions during build

Rootless Image Tags

Each regular tag has a corresponding rootless version with the -rootless suffix:
  • latest-rootless (experimental)
  • stable-rootless (experimental)
  • 2.0.55-rootless (experimental)

Quick Start with Rootless

docker run -d \
  -p 34197:34197/udp \
  -p 27015:27015/tcp \
  -v ~/factorio:/factorio \
  --name factorio \
  --restart=unless-stopped \
  factoriotools/factorio:stable-rootless

Key differences:
  • No chown command needed
  • No PUID/PGID environment variables
  • Runs as UID 1000 by default
  • No permission issues with volumes

When to Use Rootless Images

Consider using rootless images if you:
  • Are running Docker in rootless mode
  • Experience permission issues with volume mounts
  • Want to avoid containers running as root
  • Don't need dynamic UID/GID mapping via PUID/PGID

Limitations

  • PUID/PGID environment variables are not supported
  • Fixed to UID 1000 (may not match your host user)
  • Experimental feature - may have undiscovered issues

Troubleshooting

Permission Issues

If you're experiencing permission errors such as:
  • chown: Operation not permitted
  • Permission denied [/factorio/saves]
  • Util.cpp:81: Operation not permitted
  • Files owned by unexpected UIDs (like 100844 instead of 845)

Please refer to our comprehensive Permission Issues Guide for detailed solutions. Common fixes include:
  • Updating Docker to version 20.x or newer (this resolves many issues)
  • Using the rootless image variants (e.g., factoriotools/factorio:stable-rootless)
  • Setting correct ownership for your specific Docker configuration

My server is listed in the server browser, but nobody can connect

Check the logs. If there is the line Own address is RIGHT IP:WRONG PORT, then this could be caused by the Docker proxy. If the the IP and port is correct it's probably a port forwarding or firewall issue instead.
By default, Docker routes traffic through a proxy. The proxy changes the source UDP port, so the wrong port is detected. See the forum post Incorrect port detected for docker hosted server for details.
To fix the incorrect port, start the Docker service with the --userland-proxy=false switch. Docker will route traffic with iptables rules instead of a proxy. Add the switch to the DOCKER_OPTS environment variable or ExecStart in the Docker systemd service definition. The specifics vary by operating system.

When I run a server on a port besides 34197 nobody can connect from the server browser

Use the PORT environment variable to start the server on the a different port, .e.g. docker run -e "PORT=34198". This changes the source port on the packets used for port detection. -p 34198:34197 works fine for private servers, but the server browser detects the wrong port.

Contributors

  • dtandersen - Maintainer
  • Fank - Programmer of the Factorio watchdog that keeps the version up-to-date.
  • SuperSandro2000 - CI Guy, Maintainer and runner of the Factorio watchdog. Contributed version updates and wrote the Travis scripts.
  • DBendit - Coded admin list, ban list support and contributed version updates
  • Zopanix - Original Author
  • Rfvgyhn - Coded randomly generated RCON password
  • gnomus - Coded white listing support
  • bplein - Coded scenario support
  • jaredledvina - Contributed version updates
  • carlbennett - Contributed version updates and bugfixes

Example 1: Enable all by using true Example 2: Enable all by listing the mod names space-age elevated-rails quality
Example 3: Enable only Elevated rails elevated-rails

Check the logs first

Nine times out of ten the logs tell you exactly what went wrong.

  • In Portainer, go to Containers, click the container, then Logs. Or run docker logs <container>
  • Exit codes help too: 137 means killed, usually out of memory. 126 or 127 means the command inside the image is broken.

Port already in use

If deployment fails with "Bind for 0.0.0.0:34197 failed: port is already allocated", something else on your server is using that port.

  • Find what's using it: sudo ss -tlnp | grep :34197
  • Stop the other service, or pick a different host port. In 34197:34197 only the left number is yours to change, the right one belongs to the app.

Image won't pull

Test the pull directly on the host: docker pull factoriotools/factorio:stable

  • "manifest unknown" means the tag no longer exists.
  • "toomanyrequests" is the Docker Hub rate limit. Log in with docker login to raise it.
  • "no space left on device" means a full disk. Reclaim space with docker system prune

"exec format error"

This means the image was built for a different CPU architecture than your server.

  • This image supports: amd64, arm64
  • Check yours with uname -m: x86_64 is amd64, aarch64 is arm64. Raspberry Pi and other ARM boards are the usual culprits.

Container keeps restarting

The unless-stopped restart policy relaunches the app after every crash, so the real error can scroll past.

  • Check the logs right after a restart, the last few lines before it died are the useful ones.
  • Get the exit code with docker inspect <container> --format '{{.State.ExitCode}}'
  • Still stuck? Redeploy once with the restart policy set to no so the failure stays visible.

Stack won't deploy

Compose stacks fail fast on small mistakes, and Portainer shows the reason just above the editor.

  • YAML only accepts spaces for indentation, a single tab breaks the whole file.

Raise an issue

Found something which isn't working as it should? Here's how to report it.

A Compose stack

Factorio Server is a Compose stack, a set of containers defined in one file and brought up together by Portainer, then started and stopped as a single app.

The app image

An image is the app packed up ready to go, everything Factorio Server needs bundled into one download. This template pulls factoriotools/factorio:stable, which Docker fetches once (about 214 MB) and then starts your own copy from.

Where the image comes from

Docker pulls its images from registries, public libraries of ready-built apps. Factorio Server's comes from Docker Hub, published by factoriotools.

Version tags

The bit after the colon in the image name is the version tag. This one pins stable, so every redeploy gives you that exact build until you bump it yourself.

Which machines it runs on

Every image is built for particular CPU types. This one ships for amd64, arm64, so it runs on both regular x86 servers and ARM boards like a Raspberry Pi.

Ports

A port is the door the app answers on. A mapping like 34197:34197 means it's reachable on port 34197 of your server, where the left number is yours to change and the right one belongs to the app. It opens:

  • 34197:34197 over UDP

Volumes

A volume is where Factorio Server keeps its files so they survive an update or a restart. Without one, anything it saves would sit inside the container and vanish the moment it's recreated. This template mounts:

  • /factorio kept in the factoriodata volume Docker manages

Environment variables

Environment variables are the settings you hand over when you deploy, things like a password or a timezone. Factorio Server takes 4 of them, all with defaults you can leave alone or tweak:

  • LOAD_LATEST_SAVE, defaults to true
  • GENERATE_NEW_SAVE, defaults to true
  • SAVE_NAME, defaults to miget
  • UPDATE_MODS_ON_START, defaults to false

Restart policy

The restart policy here is unless-stopped, so Docker restarts Factorio Server after a crash or reboot, but leaves it off when you stop it on purpose. You can change this on the deploy screen. The choices are no (never restart), on-failure (only after a crash), unless-stopped (restart unless you stop it), and always (bring it back no matter what).

Networking

Nothing custom is set, so Factorio Server sits on Docker's default bridge network: its own private space that reaches the outside world only through the ports it publishes.

Container name

Once it's deployed, Portainer names the container factorio. That's what you'll spot in the containers list and use in commands like docker logs factorio.

Platform

The platform is linux, the kind of system the container is built to run on. Docker and Portainer handle this on a normal Linux server.

Portainer app templates

Zooming out, this whole page comes from a Portainer app template: a short recipe telling Portainer how to set Factorio Server up. Add the template list to Portainer once, then deploying Factorio Server is a click rather than a wall of config.