cweagans / docker-bg-sync

A container that syncs files between two configurable directories.
224 stars 39 forks source link

avoid error user/group already exists #21

Open danielozano opened 6 years ago

danielozano commented 6 years ago

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 commented 6 years ago

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!