itzg / itzg/docker-minecraft-bedrock-server

Container running as UID 0 despite named volume being owned by other user

Open
#210 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
1.9k
Forks
302
Avg merge
2h 26m
Merged PRs (30d)
2

Description

### Issue
If I pre-create a named volume as per your instructions:

> `docker run --rm -v minecraft:/data alpine chown 1100:1100 /data`

and then docker-compose up, the volume permissions are changed back to root, and the demoter matches to UID=0, running the container as root.

I've confirmed that the chown is working ok, and the permissions are correct on the filesystem before docker-compose up is run:

> `ls -aln /var/lib/docker/volumes/minecraft/`
> `drwxr-xr-x 14 1100 1100 4096 Jan 28 13:40 _data`

But afterwards, they've been changed to UID/GID 0. I assume the volume is having its permissions changed to suit the initial docker user (root) before the demotion happens.

### Fix
I've found that by `touch`ing a file in the named volume first, and then running the chown on the whole folder, everything works as expected and the container runs as GID 1100:

> `docker run --rm -v minecraft:/data alpine sh -c "touch /data/.initialised && chown -R 1100:1100 /data"`

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the named volume and the documented docker-compose setup, then inspect the container startup and UID-demotion behavior. Done means the volume remains owned by UID/GID 1100 after startup and the container does not run as root; no source file or test is identified in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.