Building docker container fails with "addgroup: gid '100' in use"

i know my way around Linux but am new with web services. and i’m stuck at step 1 of the installation of the docker container on a fresh debian 12 installation.

elseone had the same problem, solved it and didn’t share the solution.

they only said that it was something about permissions. so instead of using root for everything i added my user to the docker group but this didn’t solve the problem.

akkoma $ ./docker-resources/ 
Building akkoma
Sending build context to Docker daemon  312.3MB
Step 1/16 : FROM hexpm/elixir:1.14.3-erlang-25.3-alpine-3.17.2
 ---> 7523edc79a1d
Step 2/16 : ENV MIX_ENV=prod
 ---> Using cache
 ---> 4336b1448222
 ---> Using cache
 ---> a60f5f3bc2f9
Step 4/16 : ARG HOME=/opt/akkoma
 ---> Using cache
 ---> e844c7d76221
Step 5/16 : LABEL org.opencontainers.image.title="akkoma"     org.opencontainers.image.description="Akkoma for Docker"     org.opencontainers.image.vendor=""     org.opencontainers.image.documentation=""     org.opencontainers.image.licenses="AGPL-3.0"     org.opencontainers.image.url=""     org.opencontainers.image.revision=$VCS_REF     org.opencontainers.image.created=$BUILD_DATE
 ---> Using cache
 ---> dee90d24bd61
Step 6/16 : RUN apk add git gcc g++ musl-dev make cmake file-dev exiftool ffmpeg imagemagick libmagic ncurses postgresql-client
 ---> Using cache
 ---> 0c8c6a5698ee
Step 7/16 : EXPOSE 4000
 ---> Using cache
 ---> 908a2b8d06ce
Step 8/16 : ARG UID=1000
 ---> Using cache
 ---> 683ef850f87b
Step 9/16 : ARG GID=1000
 ---> Running in 1f65f360a8f7
Removing intermediate container 1f65f360a8f7
 ---> 87ae1bf62794
Step 10/16 : ARG UNAME=akkoma
 ---> Running in 25dff742f116
Removing intermediate container 25dff742f116
 ---> 9ef5648bb1b6
Step 11/16 : RUN addgroup -g $GID $UNAME
 ---> Running in befbdc0bd36e
addgroup: gid '100' in use
The command '/bin/sh -c addgroup -g $GID $UNAME' returned a non-zero code: 1
ERROR: Service 'akkoma' failed to build : Build failed
Building db
Sending build context to Docker daemon  2.048kB
Step 1/7 : FROM postgres:14-alpine
 ---> 2e0bc99c553f
Step 2/7 : ARG UID=1000
 ---> Using cache
 ---> 53d4504378e0
Step 3/7 : ARG GID=1000
 ---> Using cache
 ---> a5cf8519d434
Step 4/7 : ARG UNAME=akkoma
 ---> Using cache
 ---> 93078f634c0d
Step 5/7 : RUN addgroup -g $GID $UNAME
 ---> Running in e4005a300114
addgroup: gid '100' in use
The command '/bin/sh -c addgroup -g $GID $UNAME' returned a non-zero code: 1
ERROR: Service 'db' failed to build : Build failed

pls halp

edit: searching for permission issues with docker of course only yields links to people not knowing how to set up groups to use docker without sudo.

OK. In my case there was a permission mismatch. It’s been around a month or so since I fixed this, so my memory could be a bit off.

I believe by default, docker will create all of it’s working folders as the root user on your system, I think I was trying to run the update/upgrade with just my regular user causing this build to fail.

This seems like it’s on a fresh install? If you’ve just added your user to the docker group, make sure you logout and log back in to your linux system to make sure those permissions take effect. After that, I would delete any working directories that docker might have already created from running your docker-compose. Then try again.

You could also just try running your docker-compose with a sudo in front of it. That might be a quick fix.

i made it.
in ./docker-resources/ UID and GID are set to the ones of the user running it.
in the dockerfiles (./Dockerfile and ./docker-resources/database/Dockerfile) these vars are set to 1000 each, but the subsequent addgroup and adduser commands use the values from the build script.

i fixed it by replacing all occurences of $GID with 1000 in the two Dockerfiles.

thank you for your help.