Set UID/GID for the php-fpm container: to fix file permissions on the host #4

Open
opened 2021-12-06 13:28:47 +00:00 by 3wordchant · 2 comments
Owner

Currently:

➜ ls -l src/vendor/
total 4
-rw-r--r--. 1 root root 178 Dec  6 15:27 autoload.php
drwxr-xr-x. 1 root root  22 Dec  6 15:26 bin
drwxr-xr-x. 1 root root 426 Dec  6 15:27 composer

We should be able to set the user and the group id that docker uses for the php-fpm container -- if we set these to the same user that's running docker-compose, then the file permissions should Just Work™.

Currently: ``` ➜ ls -l src/vendor/ total 4 -rw-r--r--. 1 root root 178 Dec 6 15:27 autoload.php drwxr-xr-x. 1 root root 22 Dec 6 15:26 bin drwxr-xr-x. 1 root root 426 Dec 6 15:27 composer ``` We should be able to set the user and the group id that docker uses for the php-fpm container -- if we set these to the same user that's running docker-compose, then the file permissions should Just Work™.
3wordchant added the
enhancement
label 2021-12-08 08:49:44 +00:00
Author
Owner
https://newbedev.com/export-current-user-id-in-makefile-for-docker-compose https://jtreminio.com/blog/running-docker-containers-as-current-host-user/ https://stackoverflow.com/a/66112924/14269772
Author
Owner

Adding user: 1000:1000 to the php-fpm container "sort of works".

Two issues:

  1. No way to parameterise this while using docker-compose, that's one of the things that has pushed other projects to using a Makefile
  2. The php-fpm container's /etc/passwd doesn't contain an entry for UID 1000, so SSH (including git-over-ssh) doesn't work because it requires a properly-created home directory.

Solving #2 worsens #1 because the UID 1000 assumption is even more hard-coded if we create the user at image build time.

Solving #1 worsens 2 because it's even harder to add a user dynamically with an arbitrary UID (especially.. what if clashes?)

I am currently polling Autonomicans to find out how many people are using a non-1000 UID to see if we can maybe just continue with that default and improve it.

Adding `user: 1000:1000` to the php-fpm container "sort of works". Two issues: 1. No way to parameterise this while using `docker-compose`, that's one of the things that has pushed other projects to using a Makefile 2. The php-fpm container's `/etc/passwd` doesn't contain an entry for UID 1000, so SSH (including git-over-ssh) doesn't work because it requires a properly-created home directory. Solving #2 worsens #1 because the UID 1000 assumption is even more hard-coded if we create the user at image build time. Solving #1 worsens 2 because it's even harder to add a user dynamically with an arbitrary UID (especially.. what if clashes?) I am currently polling Autonomicans to find out how many people are using a non-1000 UID to see if we can maybe just continue with that default and improve it.
This repo is archived. You cannot comment on issues.
No Milestone
No project
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: autonomic-cooperative/wordpress-bedrock-template#4
No description provided.