Docker - Error: adduser: The UID 0 is already in use

Viewed 1152

When I'm running docker compose, I'm getting this error:

adduser: The UID 0 is already in use.
ERROR: Service 'project-be' failed to build: The command '/bin/sh -c adduser -u ${UID} --disabled-password --gecos "" appuser' returned a non-zero code: 1

My Docker version is 19.03.6.

Any suggestion is welcome, thaks a lot

1 Answers

I try to guess you (missing) docker file:

FROM some_image

# ...

RUN adduser -u ${UID} --disabled-password --gecos "" appuser

# ...

The docker build, unless specified by the image your inheriting from, runs under the root account, then the UID value is 0. So you cannot create another user with the same ID.

Are you trying to create a root user? If the answer is yes, you should create a new user, then give it root grants.

FROM some_image

# ... 

RUN adduser appuser
RUN usermod -aG sudo appuser

# ...

Please tell me if I missed something.

Related