php icon indicating copy to clipboard operation
php copied to clipboard

Building image with own UID=xxxxxx and GID =100

Open Nguimjeu opened this issue 2 years ago • 2 comments

Because of non-matching UID/GID between host system and the wodby/php image, I'm trying to build my own image (for development purposes). The build process however fails when trying to delete the group the I gave as parameter. Here the details:

My en_make file.

// ./en_make

PHP_VER=8.1.10
PHP_DEV=1
WODBY_USER_ID=1853894834
WODBY_GROUP_ID=100

The WODBY_USER_ID and WODBY_GROUP_ID correspond to the UID and primary GID of my user on the host system.

The command I use to launch the build process.

$ make buildx-build-amd64

Build output with error message (truncated):

docker buildx build --platform linux/amd64 -t wodby/php:8.1-dev \
        --build-arg PHP_VER=8.1.10 \
        --build-arg PHP_DEV=1 \
        --build-arg WODBY_USER_ID=1853894834 \
        --build-arg WODBY_GROUP_ID=100 \
        --build-arg PECL_HTTP_PROXY="" \
        --load \
        ./
[+] Building 2.5s (6/10)                                                                                                                                                                                                         
 => [internal] load build definition from Dockerfile   

...
 => ERROR [2/6] RUN set -xe;         existing_group=$(getent group "${WODBY_GROUP_ID}" | cut -d: -f1); ...

...

#0 0.603 + getent group 100
#0 0.604 + cut -d: -f1
#0 0.604 + existing_group=users
#0 0.604 + '[[' -n users ]]
#0 0.605 + delgroup users
#0 0.605 delgroup: 'guest' still has 'users' as their primary group!

...

make: *** [Makefile:55: buildx-build-amd64] Error 1

If I'm not wrong, the build process fails because it is trying to delete the group with id 100.

Question:

While the user on my host system belongs to other groups that I can use for the build process, is it possible, instead of trying to delete the group, to add the user to the existing group in the docker image?

Nguimjeu avatar Sep 27 '22 12:09 Nguimjeu

well, it's definitely possible :)

but do you really need it? isn't matching uid sufficient for dev purposes?

csandanov avatar Sep 28 '22 06:09 csandanov

well, it's definitely possible :)

but do you really need it? isn't matching uid sufficient for dev purposes?

Hey thanks for looking into it. TBH, up until now, using a group ID other than the primary host GID to create the user in the container has not made problems. I may be a little bit obsessed :-D about having UID/GID to match between host and container, as it looks more "seamless". To visualize a bit, here is example oupt of directory listing that I currently have:

λ ls -la
total 716
drwxrwxr-x 14 johndoe php linux vdi users      4096 Sep 20 11:56 .
drwxr-xr-x  6 johndoe users                    4096 Sep  6 11:36 ..
-rwxrwxr-x  1 johndoe users                    6225 Sep  8 15:21 composer.json
-rwxr-xr-x  1 johndoe users                  532263 Sep  8 15:21 composer.lock
drwxrwxr-x  3 johndoe users                    4096 Jun 30 15:28 config
-rw-r--r--  1 johndoe users                   11878 Sep  7 11:55 docker-compose.yml
-rw-r--r--  1 johndoe users                       5 Sep  7 11:55 .dockerignore
-rw-r--r--  1 johndoe users                    2926 Sep  7 11:55 docker.mk
drwxrwxr-x  4 johndoe users                    4096 Sep  7 11:55 drush
-rwxrwxr-x  1 johndoe php linux developer       357 Jun 30 15:34 .editorconfig         // <--- created/modified in wodby container
-rwxrwxr-x  1 johndoe users                    2938 Sep 20 11:56 .env
-rw-r--r--  1 johndoe users                    2724 Sep  7 11:55 .env.dist
drwxrwxr-x  8 johndoe users                    4096 Sep 14 12:55 .git
-rwxrwxr-x  1 johndoe php linux developer      3858 Jun 30 15:34 .gitattributes        // <--- created/modified in wodby container
-rw-r--r--  1 johndoe users                     893 Sep  7 11:55 .gitignore
drwxrwxr-x  3 johndoe users                    4096 Sep 22 09:46 .idea
-rw-r--r--  1 johndoe users                     391 Sep  7 11:55 load.environment.php
-rw-r--r--  1 johndoe users                     128 Sep  7 11:55 Makefile
-rwxrwxr-x  1 johndoe users                    1837 Jul  5 09:15 phpunit.xml
-rw-r--r--  1 johndoe users                    1692 Sep  7 11:55 phpunit.xml.dist
-rw-r--r--  1 johndoe users                    7897 Sep  7 11:55 README.md
drwxrwxr-x  7 johndoe users                    4096 Jul 14 09:26 tests
drwxrwxr-x 64 johndoe php linux developer      4096 Sep  8 15:21 vendor               // <--- created/modified in wodby container
drwxrwxr-x  8 johndoe users                    4096 Sep  8 11:01 web

Nguimjeu avatar Sep 28 '22 07:09 Nguimjeu