I am using Docker compose and a launch script written in Python to run a few containers with a game server instance in each one. The container and dependencies etc. spin up fine, however, as soon as the dedicated server for the game itself launches I get errors based on inabilities to create files and directories in the bind mount.
I already have other instances of other games working and writing to bind mounts successfully with single files determined by myself.
This particular game runs on Java and has file and DB creation built into the launch, I'm seeing the following errors:
pztest | ERROR: General , 1696543719203> 1,106,355,549> java.nio.file.AccessDeniedException: /home/pz
pztest | ERROR: General , 1696543719207> 1,106,355,553> java.io.FileNotFoundException: /home/pz/Zomboid/backups/version/backup_1.zip (No such file or directory)
I don't understand how the process can fail to create files in exactly the same directory when the same user running the process can do it successfully.
I've tried using the same script to create config files and write them to the bind mount using the same user. This is completing successfully.
I've checked the UID and GID for the user a few times and everything matches, permissions set correctly for directory on the host machine. Is there something I'm missing in terms of specific processes having thier own UID's, or perhaps something to do with the Java Version I'm running?!
Any help/ideas here would be very gratefully received. I've been at this 16 hours :D !
Compose File
version: '3'
services:
pz1:
build:
context: .
dockerfile: "pz_test_dockerfile"
image: "pz_image:1.0"
volumes:
- "/home/servers/pz/test_server:/pz/Zomboid/"
container_name: "pztest"
environment:
sv_ref: "testserver"
ports:
- "16259:16260/udp"
- "16259:16260/tcp"
command: [/pz/pz_launch.py]
Dockerfile
FROM ubuntu:latest
# Add multiverse repository and install necessary tools
RUN apt-get update && apt-get install -y \
software-properties-common curl && \
add-apt-repository multiverse && \
apt-get update
# Install 32-bit architecture support and dependencies
RUN dpkg --add-architecture i386 && \
DEBIAN_FRONTEND=noninteractive \
apt-get update && \
apt-get install --no-install-recommends --assume-yes \
libc6:i386 libncurses5:i386 libstdc++6:i386 openjdk-11-jre-headless python3 \
&& apt-get clean
RUN mkdir -p /opt/steamcmd && \
groupadd -g 1016 servers && \
useradd -g 1016 -u 1015 pz
# Copy over Addon Files & Python Script
COPY --chown=pz:1016 pz_launch.py /pz/pz_launch.py
COPY --chown=pz:1016 pz_settings.py /pz/pz_settings.py
COPY --chown=pz:1016 server.ini /pz/server.ini
COPY --chown=pz:1016 servercvars.lua /pz/servercvars.lua
RUN curl -s https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz | tar -vxz -C /opt/steamcmd
RUN /opt/steamcmd/steamcmd.sh +quit
# Change ownership and exec. of the files
RUN chmod 775 /pz/ \
&& chmod +x /pz/pz_launch.py \
&& chmod +x /pz/pz_settings.py \
&& chmod +x /opt/steamcmd/steamcmd.sh \
&& chown -R pz:1016 /opt/ \
&& chown -R pz:1016 /pz/
# Change to PZ user
USER pz
The entry point script is using the User Created as the starting PATH. So for e.g.
The Dockerfile ends on
USER pz
So the starting PATH for the python entrypoint script was /pz/ As per the application output, it's looking for an absolute path of /home/pz.