docker-bg-sync icon indicating copy to clipboard operation
docker-bg-sync copied to clipboard

avoid error user/group already exists

Open danielozano opened this issue 6 years ago • 1 comments

Hi! First of all thanks a lot for your work!

Working with this image I found an error, when you use the env variables: UNISON_USER, UNISON_GROUP, UNISON_GID, UNISON_UID. The container fails when you run docker-compose up after the first time.

The problem is that the user/group are created inside a script, that is executed every time you turn on the container. So if the user/group already exists (they are created the first time you build the container) it will fail: addgroup: group 'NAME' in use, and the same for the user.

So you've the option of always use --build when turning on the container.

The ideal solution should be delete the user/group and create them again, because you could've only changed the GID/UID. But as you're using alpine groupdel/userdel are not available and I don't want to install anything in your image!

So in resume, I've just added a check that will only create the user/group when they doesn't exists.

Regards!

(If you want to reproduce it, just set the env variables and run docker-compose up SERVICE_NAME twice, the second time it should fail)

danielozano avatar Jul 24 '18 22:07 danielozano

I didn't notice about #18 . It's already fixed there. If you want I can just close the PR!

Thanks, and sorry for not take a look at the already existing PRs!

danielozano avatar Jul 24 '18 22:07 danielozano