factoriotools / factorio-docker

Factorio headless server in a Docker container
https://hub.docker.com/r/factoriotools/factorio/
MIT License
1.08k stars 241 forks source link

Error: filesystem error: copy_file "/factorio/temp/currently-playing/level.dat" failed: Permission denied #549

Open aSemy opened 1 week ago

aSemy commented 1 week ago

Hi, I'm getting persistent permission errors when trying to run the Factorio server on my Macbook.

This is the Dockerfile I'm using:

services:

  factorio-server:
    image: factoriotools/factorio:${FACTORIO_VERSION}
    container_name: "factorio-server"
    restart: "no"
    ports:
      - "34197:34197/udp" # factorio
      - "27015:27015/tcp" # rcon
    volumes:
      - "./factorio-server:/factorio"
    environment:
      PUID: ${FACTORIO_SERVER_USER_ID}
      PGID: ${FACTORIO_SERVER_GROUP_ID}

And the .env file:

FACTORIO_SERVER_GROUP_ID=20
FACTORIO_SERVER_USER_ID=502
FACTORIO_VERSION=2.0.16

However, I can't seem to get this working at all. I've tried owning the ./factorio-server/ dir with the Factorio uid:845 user (and removing the custom PUID and PGID), or as my current user, but I can't figure out the necessary combination...

I've deleted the files and container, and restarted my machine.

Versions

Logs

2024-11-16T11:44:34.485784410Z +++ readlink -f /docker-entrypoint.sh
2024-11-16T11:44:34.485997655Z ++ dirname /docker-entrypoint.sh
2024-11-16T11:44:34.486319107Z + INSTALLED_DIRECTORY=/
2024-11-16T11:44:34.487166424Z + FACTORIO_VOL=/factorio
2024-11-16T11:44:34.487177174Z + LOAD_LATEST_SAVE=true
2024-11-16T11:44:34.487182298Z + GENERATE_NEW_SAVE=false
2024-11-16T11:44:34.487185965Z + PRESET=
2024-11-16T11:44:34.487189673Z + SAVE_NAME=
2024-11-16T11:44:34.487193048Z + BIND=
2024-11-16T11:44:34.487196631Z + CONSOLE_LOG_LOCATION=
2024-11-16T11:44:34.487199923Z + mkdir -p /factorio
2024-11-16T11:44:34.487274422Z + mkdir -p /factorio/saves
2024-11-16T11:44:34.487767412Z + mkdir -p /factorio/config
2024-11-16T11:44:34.488901848Z + mkdir -p /factorio/mods
2024-11-16T11:44:34.490234988Z + mkdir -p /factorio/scenarios
2024-11-16T11:44:34.491749416Z + mkdir -p /factorio/script-output
2024-11-16T11:44:34.492794145Z + [[ ! -f /factorio/config/rconpw ]]
2024-11-16T11:44:34.492808353Z + [[ ! -f /factorio/config/server-settings.json ]]
2024-11-16T11:44:34.492813312Z + [[ ! -f /factorio/config/map-gen-settings.json ]]
2024-11-16T11:44:34.492817353Z + [[ ! -f /factorio/config/map-settings.json ]]
2024-11-16T11:44:34.492824061Z ++ find -L /factorio/saves -iname '*.tmp.zip' -mindepth 1
2024-11-16T11:44:34.494663233Z ++ wc -l
2024-11-16T11:44:34.494676774Z + NRTMPSAVES=0
2024-11-16T11:44:34.494680816Z + [[ 0 -gt 0 ]]
2024-11-16T11:44:34.494992268Z + [[ '' == \t\r\u\e ]]
2024-11-16T11:44:34.495214639Z + //docker-dlc.sh
2024-11-16T11:44:34.495357219Z Enable mod elevated-rails for DLC
2024-11-16T11:44:34.518520551Z Enable mod quality for DLC
2024-11-16T11:44:34.544449285Z Enable mod space-age for DLC
2024-11-16T11:44:34.579877664Z + EXEC=
2024-11-16T11:44:34.580392362Z ++ id -u
2024-11-16T11:44:34.580868770Z + [[ 0 == 0 ]]
2024-11-16T11:44:34.580934435Z + usermod -o -u 845 factorio
2024-11-16T11:44:34.581720836Z usermod: no changes
2024-11-16T11:44:34.581816167Z + groupmod -o -g 845 factorio
2024-11-16T11:44:34.584883231Z + chown -R factorio:factorio /factorio
2024-11-16T11:44:34.586898400Z + EXEC='runuser -u factorio -g factorio --'
2024-11-16T11:44:34.586943482Z + [[ -f /bin/box64 ]]
2024-11-16T11:44:34.587015564Z + EXEC='runuser -u factorio -g factorio -- /bin/box64'
2024-11-16T11:44:34.587031564Z + sed -i '/write-data=/c\write-data=\/factorio/' /opt/factorio/config/config.ini
2024-11-16T11:44:34.587988586Z ++ find -L /factorio/saves -iname '*.zip' -mindepth 1
2024-11-16T11:44:34.588451619Z ++ wc -l
2024-11-16T11:44:34.588981108Z + NRSAVES=0
2024-11-16T11:44:34.588994108Z + [[ false != true ]]
2024-11-16T11:44:34.589033107Z + [[ 0 == 0 ]]
2024-11-16T11:44:34.589042732Z + GENERATE_NEW_SAVE=true
2024-11-16T11:44:34.589050607Z + SAVE_NAME=_autosave1
2024-11-16T11:44:34.589112481Z + [[ true == true ]]
2024-11-16T11:44:34.589121939Z + [[ -z _autosave1 ]]
2024-11-16T11:44:34.589128980Z + [[ -f /factorio/saves/_autosave1.zip ]]
2024-11-16T11:44:34.589204979Z + [[ ! -z '' ]]
2024-11-16T11:44:34.589238478Z + runuser -u factorio -g factorio -- /bin/box64 /opt/factorio/bin/x64/factorio --create /factorio/saves/_autosave1.zip --map-gen-settings /factorio/config/map-gen-settings.json --map-settings /factorio/config/map-settings.json
2024-11-16T11:44:34.912607467Z    0.001 2024-11-16 11:44:34; Factorio 2.0.16 (build 80214, linux64, headless, space-age)
2024-11-16T11:44:34.913803527Z    0.002 Operating system: Linux
2024-11-16T11:44:34.914374599Z    0.003 Program arguments: "/opt/factorio/bin/x64/factorio" "--create" "/factorio/saves/_autosave1.zip" "--map-gen-settings" "/factorio/config/map-gen-settings.json" "--map-settings" "/factorio/config/map-settings.json" 
2024-11-16T11:44:34.914483138Z    0.003 Config path: /opt/factorio/config/config.ini
2024-11-16T11:44:34.916418017Z    0.004 Read data path: /opt/factorio/data
2024-11-16T11:44:34.916435725Z    0.004 Write data path: /factorio [220900/948584MB]
2024-11-16T11:44:34.916442391Z    0.004 Binaries path: /opt/factorio/bin
2024-11-16T11:44:34.930879438Z    0.019 System info: [CPU:                             Box64 on - @1000 MHz, 2 cores, RAM: 1959 MB]
2024-11-16T11:44:34.931352511Z    0.020 Environment: DISPLAY=<unset> WAYLAND_DISPLAY=<unset> DESKTOP_SESSION=<unset> XDG_SESSION_DESKTOP=<unset> XDG_CURRENT_DESKTOP=<unset> SDL_VIDEODRIVER=<unset> __GL_FSAA_MODE=<unset> __GL_LOG_MAX_ANISO=<unset> __GL_SYNC_TO_VBLANK=<unset> __GL_SORT_FBCONFIGS=<unset> __GL_YIELD=<unset>
2024-11-16T11:44:34.940323375Z    0.029 Running in headless mode
2024-11-16T11:44:34.940598911Z    0.029 Audio is disabled
2024-11-16T11:44:34.947550814Z    0.036 Info ModManager.cpp:434: FeatureFlag expansion-shaders = true
2024-11-16T11:44:34.947832017Z    0.036 Info ModManager.cpp:434: FeatureFlag freezing = true
2024-11-16T11:44:34.947957890Z    0.037 Info ModManager.cpp:434: FeatureFlag quality = true
2024-11-16T11:44:34.948042930Z    0.037 Info ModManager.cpp:434: FeatureFlag rail-bridges = true
2024-11-16T11:44:34.948147928Z    0.037 Info ModManager.cpp:434: FeatureFlag segmented-units = true
2024-11-16T11:44:34.948259717Z    0.037 Info ModManager.cpp:434: FeatureFlag space-travel = true
2024-11-16T11:44:34.948325924Z    0.037 Info ModManager.cpp:434: FeatureFlag spoiling = true
2024-11-16T11:44:34.968766018Z    0.057 Loading mod core 0.0.0 (data.lua)
2024-11-16T11:44:34.992095179Z    0.081 Loading mod base 2.0.16 (data.lua)
2024-11-16T11:44:35.195975315Z    0.285 Loading mod elevated-rails 2.0.16 (data.lua)
2024-11-16T11:44:35.236464085Z    0.325 Loading mod quality 2.0.16 (data.lua)
2024-11-16T11:44:35.260749896Z    0.349 Loading mod space-age 2.0.16 (data.lua)
2024-11-16T11:44:35.577976379Z    0.666 Loading mod base 2.0.16 (data-updates.lua)
2024-11-16T11:44:35.605558256Z    0.694 Loading mod quality 2.0.16 (data-updates.lua)
2024-11-16T11:44:35.654925990Z    0.743 Loading mod space-age 2.0.16 (data-updates.lua)
2024-11-16T11:44:35.814618815Z    0.903 Checksum for core: 1966913147
2024-11-16T11:44:35.815074891Z    0.903 Checksum of base: 3431688266
2024-11-16T11:44:35.815253596Z    0.904 Checksum of kafkatorio-events: 0
2024-11-16T11:44:35.815338136Z    0.904 Checksum of elevated-rails: 2929976872
2024-11-16T11:44:35.815477633Z    0.904 Checksum of quality: 3484764141
2024-11-16T11:44:35.815586173Z    0.904 Checksum of space-age: 3982937588
2024-11-16T11:44:36.378991307Z    1.467 Prototype list checksum: 3872509593
2024-11-16T11:44:36.427215357Z    1.516 Info PlayerData.cpp:68: Local player-data.json unavailable
2024-11-16T11:44:36.427386063Z    1.516 Info PlayerData.cpp:73: Cloud player-data.json unavailable
2024-11-16T11:44:36.439726695Z    1.528 Factorio initialised
2024-11-16T11:44:36.442473817Z    1.531 Info Main.cpp:792: Creating new map /factorio/saves/_autosave1.zip
2024-11-16T11:44:36.461797670Z    1.550 Blueprint storage "blueprint-storage-2.dat" was not found, trying to load previous version storage "blueprint-storage.dat"
2024-11-16T11:44:39.946991007Z Error: filesystem error: copy_file "/factorio/temp/currently-playing/level.dat" to "/factorio/temp/currently-playing/level-init.dat" failed: Permission denied [/factorio/temp/currently-playing/level.dat] [/factorio/temp/currently-playing/level-init.dat]
2024-11-16T11:44:39.947019381Z    5.036 Goodbye
aSemy commented 6 days ago

For investigation purposes I tried running sudo chown -R 845:845 ./factorio-server and sudo chmod -R 775 ./factorio-server, but I see a different failure.

2024-11-16T12:38:11.819830351Z +++ readlink -f /docker-entrypoint.sh
2024-11-16T12:38:11.822470441Z ++ dirname /docker-entrypoint.sh
2024-11-16T12:38:11.824062278Z + INSTALLED_DIRECTORY=/
2024-11-16T12:38:11.825827116Z + FACTORIO_VOL=/factorio
2024-11-16T12:38:11.825862241Z + LOAD_LATEST_SAVE=true
2024-11-16T12:38:11.825879991Z + GENERATE_NEW_SAVE=false
2024-11-16T12:38:11.825900866Z + PRESET=
2024-11-16T12:38:11.825906241Z + SAVE_NAME=
2024-11-16T12:38:11.825910574Z + BIND=
2024-11-16T12:38:11.825915116Z + CONSOLE_LOG_LOCATION=
2024-11-16T12:38:11.825918741Z + mkdir -p /factorio
2024-11-16T12:38:11.826225992Z + mkdir -p /factorio/saves
2024-11-16T12:38:11.827173827Z + mkdir -p /factorio/config
2024-11-16T12:38:11.828744331Z + mkdir -p /factorio/mods
2024-11-16T12:38:11.829433166Z + mkdir -p /factorio/scenarios
2024-11-16T12:38:11.830623503Z + mkdir -p /factorio/script-output
2024-11-16T12:38:11.833381843Z + [[ ! -f /factorio/config/rconpw ]]
2024-11-16T12:38:11.833590968Z + [[ ! -f /factorio/config/server-settings.json ]]
2024-11-16T12:38:11.833744469Z + [[ ! -f /factorio/config/map-gen-settings.json ]]
2024-11-16T12:38:11.833866261Z + [[ ! -f /factorio/config/map-settings.json ]]
2024-11-16T12:38:11.834243928Z ++ wc -l
2024-11-16T12:38:11.834371679Z ++ find -L /factorio/saves -iname '*.tmp.zip' -mindepth 1
2024-11-16T12:38:11.839082149Z + NRTMPSAVES=0
2024-11-16T12:38:11.839303066Z + [[ 0 -gt 0 ]]
2024-11-16T12:38:11.839431316Z + [[ '' == \t\r\u\e ]]
2024-11-16T12:38:11.839537775Z + //docker-dlc.sh
2024-11-16T12:38:11.841306987Z Enable mod elevated-rails for DLC
2024-11-16T12:38:11.841609613Z //docker-dlc.sh: line 17: /factorio/mods/mod-list.json.tmp: Permission denied