- Created PERMISSION_ISSUES_GUIDE.md with detailed solutions for permission problems
- Based on thorough analysis of issues #558, #556, #555, #549, #496, #501, #492, #420
- Includes platform-specific solutions (NixOS, macOS, Windows, Synology)
- Documents critical Docker version requirements (20.x+ recommended)
- Highlights rootless image as recommended solution for permission issues
- Added link to guide in README.md troubleshooting section
Key findings documented:
- Most "Operation not permitted" errors resolved by updating Docker
- Rootless Docker requires using actual Docker UID (e.g., 100999) not 845
- Interrupted chown operations cause inconsistent file ownership
- Rootless images avoid most permission issues entirely
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat: Add rootless Docker support
Implements #547 - Add support for rootless Docker images to avoid permission issues.
Key changes:
- Add Dockerfile.rootless that runs as UID 1000 by default
- Create simplified entrypoint script without chown operations
- Add build-rootless.py to build rootless variants with -rootless suffix
- Document rootless usage in README-ROOTLESS.md
- Update main README with rootless section
The rootless images eliminate common permission problems by:
- Running as non-root from the start (USER 1000:1000)
- Avoiding recursive chown operations that can cause race conditions
- Using open permissions (777) on directories during build
- Not supporting PUID/PGID environment variables
This provides a cleaner solution for rootless Docker users and those
experiencing permission issues with volumes.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: Address linting issues in rootless Docker implementation
- Add --no-install-recommends to apt-get install in Dockerfile
- Consolidate consecutive RUN instructions in Dockerfile
- Fix shellcheck warnings: quote variables and use -n instead of \! -z
- These changes improve best practices without affecting functionality
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* feat: Add rootless image building to CI pipeline
- Update docker-build.yml workflow to build rootless variants
- Rootless images are built after regular images with -rootless suffix
- Both use the same multi-architecture build process
- Triggered automatically when buildinfo.json changes
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* refactor: Unify build system for regular and rootless images
- Create build-unified.py that handles both regular and rootless builds
- Convert build.py and build-rootless.py to wrapper scripts for backwards compatibility
- Update CI workflow to use unified build command
- Add BUILD_MIGRATION.md documentation
- Eliminate code duplication between build scripts
- Support flexible build options: --rootless, --both, --only-stable-latest
This maintains all existing functionality while providing a cleaner, more maintainable build system.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* chore: Add Python cache to .gitignore and remove from repo
- Add __pycache__/ and Python compiled files to .gitignore
- Remove accidentally committed __pycache__ directory
- Prevent future Python cache files from being tracked
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* refactor: Replace build system with unified solution
- Remove old build.py and build-rootless.py wrapper scripts
- Rename build-unified.py to build.py as the main build script
- Delete BUILD_MIGRATION.md (no longer needed)
- Update CI workflow to use new build.py syntax
- Update documentation in CLAUDE.md and README-ROOTLESS.md
The new build system provides all functionality in a single script:
- Default: builds regular images
- --rootless: builds only rootless images
- --both: builds both regular and rootless images
- --multiarch and --push-tags: work as before
This creates a cleaner, more maintainable build system.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* docs: Consolidate rootless documentation and mark as experimental
- Remove separate README-ROOTLESS.md file
- Integrate rootless documentation into main README.md
- Mark rootless support as experimental
- Add clear documentation about limitations and use cases
- Include warning about experimental nature
This consolidates all documentation in one place and makes it clear
that rootless support is still experimental.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
Previously, update.sh would accumulate all historical versions in buildinfo.json,
leading to an ever-growing file. This change modifies the script to rebuild
buildinfo.json from scratch with only the current stable and experimental versions.
Changes:
- Replace incremental update logic with complete rebuild
- Create fresh buildinfo.json containing only latest versions
- Preserve all proper tags (stable, latest, version numbers, etc.)
- Fix bash compatibility issue with associative arrays
This ensures buildinfo.json remains clean and only contains the versions
currently being built and published.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-authored-by: Claude <noreply@anthropic.com>
The Docker builds have been failing since June 2025 with the error:
'/bin/bash: line 1: file: command not found'
This error occurs when the SHA256 checksum verification fails and the
Dockerfile attempts to run 'file' command to help debug what type of
file was downloaded. However, the 'file' package is not installed in
the debian:stable-slim base image.
This commit adds the 'file' package to the apt-get install list so that
when SHA256 verification fails, we can get better debugging information
about what was actually downloaded (e.g., whether it's an HTML error
page instead of the expected tar.xz file).
While this doesn't fix the root cause of the SHA256 failures, it will
provide better diagnostics to help identify the actual issue.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Took 55 minutes
Skip downloading built-in DLC mods (elevated-rails, quality, space-age) when UPDATE_MODS_ON_START is enabled. These mods are included with the Space Age DLC and attempting to download them separately causes "Duplicate mod" errors.
- Modified update-mods.sh to skip DLC built-in mods during updates
- Added documentation note explaining the automatic handling of DLC mods
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-authored-by: Claude <noreply@anthropic.com>
This fixes issue #517 where the auto mod updater was downloading the wrong
mod versions after updating to Space Age (Factorio 2.0). The problem was that
the version checking logic was incorrectly rejecting compatible mod versions.
Changes:
- Fixed check_game_version() to properly handle major version differences
- Game versions can now run mods designed for older major versions (backward compatibility)
- Game versions correctly reject mods requiring newer versions
- Fixed variable references in check_dependency_version()
- Added clarifying comments about the version checking behavior
This also addresses issue #468 by ensuring mods requiring newer Factorio
versions than currently installed are properly skipped.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-authored-by: Claude <noreply@anthropic.com>
* fix: Improve README tag generation to reduce clutter
- Modified update.sh to only show the latest and stable versions
- Removed duplicate major.minor version tags
- Changed from listing all versions to showing only the most relevant tags
- Fixed jq query to properly detect stable version using index() instead of contains()
This significantly reduces README pollution by showing only:
- The latest experimental version with its tags
- The current stable version with its tags
- One entry per major.minor version for older releases (removed from this commit)
Before: 60+ lines of tags with many duplicates
After: 2 lines showing only latest and stable versions
* fix: Address shellcheck warnings about subshell variable modifications
- Changed from pipeline to process substitution to avoid SC2030/SC2031 warnings
- Variables modified in the while loop are now properly preserved
- This ensures readme_tags modifications are not lost in subshells
- Add PRESET to the environment variables table
- Include detailed explanation of available preset values
- Add example showing how to use PRESET when generating a new map
- Document that PRESET is optional and only used with GENERATE_NEW_SAVE=true
Fixes#571🤖 Generated with [Claude Code](https://claude.ai/code)
Co-authored-by: Claude <noreply@anthropic.com>
- Project overview and architecture description
- Common development commands for building and testing
- Environment variables and configuration details
- Version management and automated update process
- Volume structure and data organization
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Add rcon client to container
* Explain rcon command
* Remove test container name
* Apply suggestions
Co-authored-by: Florian Kinder <florian.kinder@fankserver.com>
* Add example docker-compose file
* Clarify return code
* Switch to pre-update
* Update docker-compose.yml
Co-authored-by: Florian Kinder <florian.kinder@fankserver.com>
* Allow build support for build (/* is only possible in buildx)
* Added version information in README.md
---------
Co-authored-by: Florian Kinder <florian.kinder@fankserver.com>
* Change variable DLC_SPACE_AGE to allow listing specific Space Age mods to enable
* Adjust DLC_SPACE_AGE note
Co-authored-by: Florian Kinder <florian.kinder@fankserver.com>
---------
Co-authored-by: Florian Kinder <florian.kinder@fankserver.com>
* Update update.sh to fix SHA256 grabbing
* Update buildinfo.json reverted data so build.sh can run
* Update docker-compose.yml reverted data so build.sh can run
* Use new version API
Update latest to experimental
* fix by shellcheck
* Revert "Auto Update Factorio to version:"
This reverts commit dfd442dfda.
* Fix correct exit when online information get fails
This change enables specifying a specific save to use via the $SAVE_NAME
variable when $ENABLE_SERVER_LOAD_LATEST is false. Additionally, you can
set $ENABLE_GENERATE_NEW_MAP_SAVE to generate a map for $SAVE_NAME if
one does not already exist.
Co-authored-by: Chance Zibolski <czibolsk@redhat.com>
* allow puid/pgid to be set on stable
* update docker-entrypoint to include puid, gpid
* add quotes to env puid/pgid env vars
* add quotes for factorio-vol
* Build feature branches with branch tag
* Build short and long image tag
* Add latest and stable tag, made moving repos easier
* Only push tags to registry
* Only build tags that where changed
* Fix if and quoting, push $VERSION_SHORT
* Update MicroBadger with Webhook, closes#251
* Quote vars
* Set tag on PR, too
* Switch to hadolint docker image
due to PR not having enviroment variables and I don't want to commit my token in the script
* Only push image on master
* Quote all vars, remove useless echo/sub-shell, add shebands, fail on unset vars, enable pipefail, formatting
* Add CI including linting via hadolint nad shellcheck
* Update all base images to tag 3.9
* Switch to maintainer labels
* Quote vars
* Remove commented code
* Ignore if the folder exists
When using named containers in docker compose, it creates them with root and the factorio docker container fails to start because it doesn't have write permissions. Reproduce by using the following docker-compose file:
version: '3.2'
services:
server:
image: dtandersen/factorio:0.16.7
volumes:
- logs:/var/log
- data:/factorio
ports:
- "34197:34197/udp"
- "27015:27015/tcp"
volumes:
logs:
data:
With this proposed change, the /factorio folder is created *before* it is made a volume. This causes docker to correctly preserve the permissions, the docker-compose file above works now.
This is related to https://github.com/dtandersen/docker_factorio_server/issues/91 and maybe also makes https://github.com/dtandersen/docker_factorio_server/pull/99 obsolete.
When starting the container with `docker run -d -u $(id -u factorio):$(id -g factorio) ...`, permission is denied upon trying to create `/opt/factorio/.lock` file.
This permission tweak will allow caller to pass desired user from host to container such that the permissions are retained correctly when games are saved to the mount.
Also, it just feels wrong to run factorio as root, container or not. :)
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
This is a Docker image for running a Factorio headless server. It provides automated builds for multiple Factorio versions (stable and experimental) and supports both AMD64 and ARM64 architectures.
## Architecture
### Key Components
1.**Docker Image Build System**
-`build.py` - Unified Python script that builds both regular and rootless Docker images from `buildinfo.json`
-`docker/Dockerfile` - Main Dockerfile that creates the Factorio server image
-`docker/Dockerfile.rootless` - Dockerfile for rootless variant (runs as UID 1000)
-`buildinfo.json` - Contains version info, SHA256 checksums, and tags for all supported versions
- Supports multi-architecture builds (linux/amd64, linux/arm64) using Docker buildx
2.**Automated Updates**
-`update.sh` - Checks for new Factorio releases and updates `buildinfo.json`
- Updates README.md with new version tags
- Commits changes and tags releases automatically
- Run by GitHub Actions to keep images up-to-date
3.**Container Scripts**
-`docker/files/docker-entrypoint.sh` - Main entrypoint that configures and starts the server
-`docker/files/docker-update-mods.sh` - Updates mods on server start
# Factorio Docker Permission Issues - Solutions and Workarounds
This document provides comprehensive solutions and workarounds for permission-related issues in the Factorio Docker container, based on detailed analysis of issues #558, #556, #555, #549, #496, #501, #492, and #420.
# Set appropriate permissions (note the 'u+rwx' for write access)
sudo chmod -R u+rwx /opt/factorio
```
### Solution B: Use the Rootless Docker Image (Recommended)
The project now provides a rootless variant that runs as UID 1000, which avoids most permission issues:
```bash
docker run -d \
-p 34197:34197/udp \
-p 27015:27015/tcp \
-v /opt/factorio:/factorio \
--name factorio \
factoriotools/factorio:latest-rootless
```
**Benefits of rootless images**:
- No `chown` operations on startup
- No need to pre-create directories with specific permissions
- Works seamlessly with rootless Docker installations
- Avoids the recursive permission changes that can be interrupted
**Available rootless tags**:
-`latest-rootless`
-`stable-rootless`
-`2.0.55-rootless` (or any specific version with `-rootless` suffix)
## Platform-Specific Issues and Solutions
### NixOS with Rootless Docker
**Problem**: Permission denied errors when creating directories, even after setting ownership to 845:845. Files show ownership by UID 100844 instead of 845.
**Solutions**:
1.**Find and use your actual rootless Docker user ID**:
```bash
# Method 1: Check your user ID
id -u
# Method 2: Check existing Docker volumes for the UID Docker is using
ls -lan /path/to/other/docker/volumes
# Common rootless Docker UIDs:
# - 100999 (NixOS default)
# - 100844 (as reported in issue #558)
# - 1000 (some configurations)
# Apply the correct ownership
sudo chown -R 100999:100999 ./factorio
```
2. **Configure NixOS Docker properly**:
```nix
# In configuration.nix
virtualisation.docker.rootless = {
enable = true;
setSocketVariable = true;
};
```
3. **Port Mapping Issues**: Rootless Docker on NixOS has issues with userland-proxy that can cause random port assignments. Consider using host networking if possible.
### macOS with Colima
**Problem**: `copy_file` permission denied errors, even with correct ownership. Permission errors when running docker-dlc.sh.
2. **Use Docker Desktop instead of Colima** if the issues persist, as it has better macOS integration
3. **Specify PUID/PGID explicitly**:
```yaml
environment:
- PUID=502 # Common macOS user ID
- PGID=20 # Common macOS staff group
```
### Windows
**Problem**: Cannot remove temporary locale files due to Windows-Linux permission translation. Errors like "Permission denied trying to remove /factorio/temp/currently-playing/locale/de".
**Solutions**:
1. **Use WSL2 backend** for Docker Desktop (required for proper Linux filesystem semantics)
2. **Store volumes in WSL2 filesystem** instead of Windows filesystem:
```bash
# Inside WSL2 terminal
mkdir -p ~/factorio
chmod -R 777 ~/factorio
```
```yaml
# docker-compose.yml - use WSL2 path
volumes:
- ~/factorio:/factorio
```
3. **Avoid Windows drive mounts** (like `W:\docker\factorio`) as they have inherent permission translation issues
4. **Add :Z flag for SELinux context** (some Windows Docker setups benefit from this):
| `Couldn't create lock file /factorio/.lock` | Container can't write to volume | Check volume mount and permissions |
| `Map version X cannot be loaded` | Version mismatch | Use correct Docker image version |
## Known Issues and Limitations
### Interrupted chown Operations
The container performs `chown -R factorio:factorio /factorio` on every start. If the container is killed during this operation:
- Files will have inconsistent ownership
- Some files owned by 845, others by different UIDs
- Solution: Let the container complete startup before stopping
### Rootless Docker Port Mapping
**Issue #496**: Rootless Docker with userland-proxy causes random port assignments instead of the configured 34197.
- **Workaround**: Use host networking mode if possible
- **Note**: This is a Docker limitation, not specific to this image
### Map Version Compatibility
**Problem**: "Map version 2.0.23-0 cannot be loaded because it is higher than the game version".
**Solution**:
```bash
# Use a version that matches or exceeds your save
docker pull factoriotools/factorio:2.0.23
# Or always use latest for newest features
docker pull factoriotools/factorio:latest
```
## Recommended Approach
### For New Installations
1. **Update your system first** - Many issues are caused by old Docker versions
2. **Try the rootless image first** - It avoids most permission issues entirely
3. **Pre-create directories** with correct permissions if using the standard image
4. **Test without volumes** first to ensure the image works
### For Existing Installations with Issues
1. **Stop the container** and let it shut down cleanly
2. **Backup your data** before making changes
3. **Check Docker version** - update if below 20.x
4. **Fix permissions** using the platform-specific solution
5. **Consider rootless variant** for easier permission management
### Best Practices
- **Let the container start fully** before stopping (avoid interrupted chown)
- **Use named volumes** instead of bind mounts when possible
- **Monitor first startup** to ensure permissions are set correctly
- **Keep Docker updated** to avoid known bugs
## Community Solutions
### Proposed Improvements (from @Fank)
1. **Add USER directive** in Dockerfile after creating directories
2. **Optimize chown logic** to only run when ownership is wrong
3. **Implement fixuid** for better UID/GID mapping
4. **Add health checks** to ensure permissions are correct before starting
### Alternative Images
Some users have tried other Factorio Docker images (e.g., goofball222/factorio) but report the same Util.cpp:81 errors, suggesting this is a broader ecosystem issue related to Docker versions and system configurations.
## Quick Reference
| Platform | Common UID | Recommended Approach |
|----------|-----------|---------------------|
| Standard Docker | 845 | Update Docker, use `chown 845:845` |
| Rootless Docker (NixOS) | 100999, 100844 | Find actual UID, chown to that |
| macOS (Docker Desktop) | 502 (user), 20 (staff) | Use PUID/PGID env vars |
| Windows | N/A | Use WSL2 filesystem |
| Synology NAS | varies | Check DSM user, ensure Docker has folder access |
## Getting Help
If these solutions don't work:
1. **Update everything first** (Docker, kernel, system packages)
2. **Provide full details** when reporting issues:
- Docker version (`docker --version`)
- OS and version
- Full error messages
- Output of `ls -lan` on your volume
3.**Try the rootless image** as an alternative
4.**Check issue #558** for ongoing discussions
Remember: The vast majority of permission issues are resolved by updating Docker to version 20.x or newer!
> Support for ARM is experimental. Expect crashes and lag if you try to run this on a raspberry pi.
[中文](./README_zh_CN.md)
# What is Factorio?
<!-- start autogeneration tags -->
*`latest, 2.0.60`
*`2, 2.0, 2.0.55, stable, stable-2.0.55`
*`2.0.59`
*`stable-1.1.110, 1, 1.1, 1.1.110`
*`1.0.0, 1.0`
*`0.17.79, 0.17`
*`0.16.51, 0.16`
*`0.15.40, 0.15`
*`0.14.23, 0.14`
*`0.13.20, 0.13`
*`0.12.35, 0.12`
<!-- end autogeneration tags -->
## Tag descriptions
*`latest` - most up-to-date version (may be experimental).
*`stable` - version declared stable on [factorio.com](https://www.factorio.com) ([FFF-435 Since 2.0 versions gets released as experimental first, once stable it will be marked as stable](https://factorio.com/blog/post/fff-435)).
*`0.x` - latest version in a branch.
*`0.x.y` - a specific version.
*`0.x-z` - incremental fix for that version.
## What is Factorio?
[Factorio](https://www.factorio.com) is a game in which you build and maintain factories.
@ -11,106 +35,515 @@ You will be mining resources, researching technologies, building infrastructure,
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 game is available at [factorio.com](https://www.factorio.com) and [Steam](http://store.steampowered.com/app/427520/).
NOTE: This is only the server. The full game is available at [Factorio.com](https://www.factorio.com), [Steam](https://store.steampowered.com/app/427520/), [GOG.com](https://www.gog.com/game/factorio) and [Humble Bundle](https://www.humblebundle.com/store/factorio).
## Usage
# Usage
### Quick Start
## Quick Start
Run the server to create the necessary folder structure and configuration files. For this example data is stored in `/opt/factorio`.
Run the server to create the necessary folder structure and configuration files. For this example data is stored in `/tmp/factorio`.
```
docker run -d -P -v /tmp/factorio:/factorio --name factorio dtandersen/factorio
```shell
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 all ports.
*`-v` - Mount `/tmp/factorio` on the local file system to `/factorio` in the container.
*`-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:
```
```shell
docker logs factorio
```
Stop the server:
```
```shell
docker stop factorio
```
Now there's a `server-settings.json` file in the folder `/tmp/factorio/config`. Modify this to your liking and restart the server:
Now there's a `server-settings.json` file in the folder `/opt/factorio/config`. Modify this to your liking and restart the server:
```
```shell
docker start factorio
```
Try to connect to the server. Check the logs if it isn't working.
### Console
## Saves
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.
A new map named `save.zip` is generated the first time the server is started. The `map-gen-settings.json` file in `/tmp/factorio/config` is used for the map settings. On subsequent runs the newest save is used.
```shell
docker run -d -it \
--name factorio \
factoriotools/factorio
docker attach factorio
```
To load an old save stop the server and run the command `touch oldsave.zip`. This resets the date. Then restart the server.
### 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.
```shell
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:
```shell
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+)
## Mods
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:
```shell
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`:
```shell
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):
```shell
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](https://www.factorio.com/profile) 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.
## Remote Console
**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.
RCON is currently disabled.
### 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.
# Container Details
```shell
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
```
The philosophy is to keep things simple.
### Converting Scenarios to Regular Maps
* Self-configure to a minimal working state.
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.
```shell
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.
```json
[
"you",
"friend"
]
```
### Banlisting (0.17.1+)
Create file `config/server-banlist.json` and add the banlisted users.
```json
[
"bad_person",
"other_bad_person"
]
```
### Adminlisting (0.17.1+)
Create file `config/server-adminlist.json` and add the adminlisted users.
```json
[
"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:
| PORT | UDP port the server listens on | 34197 | 0.15+ |
| BIND | IP address (v4 or v6) the server listens on (IP\[:PORT]) | | 0.15+ |
| RCON_PORT | TCP port the rcon server listens on | 27015 | 0.15+ |
| SAVE_NAME | Name to use for the save file | _autosave1 | 0.17+ |
| PRESET | Map generation preset when GENERATE_NEW_SAVE is true | | 0.17+ |
| TOKEN | factorio.com token | | 0.17+ |
| UPDATE_MODS_ON_START | If mods should be updated before starting the server | | 0.17+ |
| USERNAME | factorio.com username | | 0.17+ |
| CONSOLE_LOG_LOCATION | Saves the console log to the specifies location | | |
| DLC_SPACE_AGE | Enables or disables the mods for DLC Space Age in mod-list.json[^1] | true | 2.0.8+ |
| MODS | Mod directory to use | /factorio/mods | 2.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](http://wiki.c2.com/?KeepItSimple).
* The server should bootstrap itself.
* Prefer configuration files over environment variables.
* Use one volume for data.
## Volumes
### 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.
```text
factorio
|-- config
| |-- map-gen-settings.json
| |-- map-settings.json
| |-- rconpw
| |-- server-adminlist.json
| |-- server-banlist.json
| |-- server-settings.json
| +-- map-gen-settings.json
| `-- server-whitelist.json
|-- mods
| |-- fancymod.zip
+-- saves
|-- _autosave1.zip
+-- save.zip
| `-- fancymod.zip
`-- saves
`-- _autosave1.zip
```
## Docker Compose
## Ports
[Docker Compose](https://docs.docker.com/compose/install/) is an easy way to run Docker containers.
*`34197/udp` - Factorio clients (required).
* docker-engine >= 1.10.0 is required
* docker-compose >=1.6.0 is required
First get a [docker-compose.yml](https://github.com/factoriotools/factorio-docker/blob/master/docker/docker-compose.yml) file. To get it from this repository:
Now cd to the directory with docker-compose.yml and run:
```shell
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`.
```json
"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.
```shell
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](https://www.vagrantup.com/) is a easy way to setup a virtual machine (VM) to run Docker. The [Factorio Vagrant box repository](https://github.com/dtandersen/factorio-lan-vagrant) 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.
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](https://github.com/m-chandler/factorio-spot-pricing). 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
```shell
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
**Server is listed in the in-game server browser, but users can't connect**
### Permission Issues
Run Docker with the `--userland-proxy=false` option. The source UDP port is changed by docker-proxy when the server pings "pingpong" servers. See [Incorrect port detected for docker hosted server](https://forums.factorio.com/viewtopic.php?f=49&t=35255).
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](./PERMISSION_ISSUES_GUIDE.md) 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
# Credits
### My server is listed in the server browser, but nobody can connect
Ideas borrowed from:
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](https://forums.factorio.com/viewtopic.php?f=49&t=35255)* 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.
* [Fank](https://github.com/Fankserver) - Programmer of the Factorio watchdog that keeps the version up-to-date.
* [SuperSandro2000](https://github.com/supersandro2000) - CI Guy, Maintainer and runner of the Factorio watchdog. Contributed version updates and wrote the Travis scripts.
* [DBendit](https://github.com/DBendit/docker_factorio_server) - Coded admin list, ban list support and contributed version updates
* [Zopanix](https://github.com/zopanix/docker_factorio_server) - Original Author
git commit -a -m "Auto Update Factorio to stable version: ${stable_online_version} experimental version: ${experimental_online_version}"
git tag -f latest
git push
git push origin --tags -f
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.