thecodingmachine / docker-images-php

A set of PHP Docker images
MIT License
785 stars 138 forks source link

Missing write permissions for "docker" home directory #256

Closed mbrodala closed 2 years ago

mbrodala commented 3 years ago

Expected Behavior

Commands can write to the home directory of docker (~, /home/docker), e.g. ~/.cache.

Current Behavior

There are permission errors, .e.g in Yarn:

yarn run v1.22.5
warning Skipping preferred cache folder "/home/docker/.cache/yarn" because it is not writable.
warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-1001".

Possible Solution

Update the owner ID of /home/docker in the image entrypoint.

Steps to Reproduce (for bugs)

  1. Have a host user with an ID different from 1000
  2. Start a container, e.g. PHP-FPM
  3. Run a command or interactive shell
  4. Try to write to /home/docker

Context

I noticed this with a Yarn installation.

The owner of /home/docker is left at 1000:

$ ls -ld ~
drwxr-xr-x 1 1000 docker 4096 Apr 11 06:00 /home/docker

However, the ID of the docker user was updated to reflect my host user:

$ id
uid=1001(docker) gid=1000(docker) groups=1000(docker),27(sudo)

Your Environment

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please update it if any action still required.

mbrodala commented 2 years ago

Seems to be fixed by now:

$ ls -ld ~
drwxr-xr-x 1 docker docker 4096 Jan  3 11:19 /home/docker
$ id
uid=1001(docker) gid=1000(docker) groups=1000(docker),27(sudo)