Docker volume permission
Build Custom Permissions into the Dockerfile
if you are using Bind Mounts (mapping a specific path on your host machine like -v /home/user/app:/app/data), the behavior depends entirely on your operating system.
Docker mounts the existing host directory directly over the container's /app/data path. The host directory's files will retain their existing host numeric ownership, which will likely conflict with your new container user (10001)
FROM alpine:latest
# Create a dedicated application group and user
RUN addgroup -g 10001 appgroup && \
adduser -u 10001 -G appgroup -D appuser
WORKDIR /app
# Create the directory and set permissions before mounting
RUN mkdir /app/data && chown -R appuser:appgroup /app/data
USER appuser
CMD ["your-application-binary"]
sudo chown -R 10001:10001 /path/to/host/dir