gis-ops / docker-valhalla

This is our flexible Docker repository for the Valhalla routing engine
MIT License
228 stars 69 forks source link

Docker build failing: groupadd: GID '1000' already exists if trying to pass local id build args #134

Closed answerquest closed 5 months ago

answerquest commented 5 months ago

OS: Ubuntu 20.04.6 LTS (GNU/Linux 5.15.0-1045-azure x86_64)

It's a server on Azure.

cd /home/azureuser/
git clone https://github.com/gis-ops/docker-valhalla.git
cd /home/azureuser/docker-valhalla
docker build -t valhalla_custom1 --no-cache --build-arg VALHALLA_UID=$(id -u $USER) --build-arg VALHALLA_GID=$(id -g $USER) .

This fails with logs:

 => ERROR [runner_base 5/8] RUN groupadd -g 1000 valhalla &&   useradd -lmu 1000 -g valhalla valhalla &&   mkdir /custom_files &&   if [ 1000 != 59999 ] || [ 1000 != 59999 ]; then chmod 0775 custom_fi  0.3s
------                                                                                                                                                                                                         
 > [runner_base 5/8] RUN groupadd -g 1000 valhalla &&   useradd -lmu 1000 -g valhalla valhalla &&   mkdir /custom_files &&   if [ 1000 != 59999 ] || [ 1000 != 59999 ]; then chmod 0775 custom_files && chown valhalla:valhalla /custom_files; else usermod -aG sudo valhalla && echo "ALL            ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers; fi:
0.224 groupadd: GID '1000' already exists
------
Dockerfile:44
--------------------
  43 |     
  44 | >>> RUN groupadd -g ${VALHALLA_GID} valhalla && \
  45 | >>>   useradd -lmu ${VALHALLA_UID} -g valhalla valhalla && \
  46 | >>>   mkdir /custom_files && \
  47 | >>>   if [ $VALHALLA_UID != 59999 ] || [ $VALHALLA_GID != 59999 ]; then chmod 0775 custom_files && chown valhalla:valhalla /custom_files; else usermod -aG sudo valhalla && echo "ALL            ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers; fi
  48 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c groupadd -g ${VALHALLA_GID} valhalla &&   useradd -lmu ${VALHALLA_UID} -g valhalla valhalla &&   mkdir /custom_files &&   if [ $VALHALLA_UID != 59999 ] || [ $VALHALLA_GID != 59999 ]; then chmod 0775 custom_files && chown valhalla:valhalla /custom_files; else usermod -aG sudo valhalla && echo \"ALL            ALL = (ALL) NOPASSWD: ALL\" >> /etc/sudoers; fi" did not complete successfully: exit code: 4

From the readme, it was advised that we pass in the local user / group ids as build args so that permissions for persistent volume stay local or something.. the link in readme is no longer working also.

nilsnolde commented 5 months ago

Smth must’ve changed in 23.04 then I guess. Good chance to get rid of that entirely, it’s a pretty annoying logic.. or if you want, you can fix it.

answerquest commented 5 months ago

Hi, I went ahead with default flow, building the image without supplying any build args, and it worked fine at downloading pbf, building the valhalla tiles in the local persistent volume folder, and running it. I checked the permissions of the contents of persistent volume and they're all under the local user only:

-rw-rw-r-- 1 azureuser azureuser 1451549425 Jan 18 13:20 india-latest.osm.pbf
drwxrwxr-x 2 azureuser azureuser       4096 Jan 18 13:22 admin_data
-rw-rw-r-- 1 azureuser azureuser        136 Jan 18 14:14 duplicateways.txt
drwxrwxr-x 5 azureuser azureuser       4096 Jan 18 14:33 valhalla_tiles
-rw-rw-r-- 1 azureuser azureuser         65 Jan 18 14:33 file_hashes.txt
-rw-rw-r-- 1 azureuser azureuser 3817789440 Jan 18 14:34 valhalla_tiles.tar

So going ahead with default stuff. Will close this issue.

nilsnolde commented 5 months ago

Well, then it must be Azure which registers a user within the docker container with UID/GID 1000. To anyone reading this in the future: try things locally, those weird services add way too many obscure layers..