Skip to content

fix(docker): Remove existing docker user when UID or GIG already exists in the image#29

Open
arntanguy wants to merge 1 commit intofrankarobotics:mainfrom
arntanguy:fix-docker
Open

fix(docker): Remove existing docker user when UID or GIG already exists in the image#29
arntanguy wants to merge 1 commit intofrankarobotics:mainfrom
arntanguy:fix-docker

Conversation

@arntanguy
Copy link
Copy Markdown

Fixes #28


# Delete existing group if it exists
RUN if getent group ${USER_GID}; then \
groupdel $(getent group ${USER_GID} | cut -d: -f1); \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this exactly do?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first checks if there is an existing group for the provided USER_GID in the docker image:

❯ getent group 100;
users:x:100:

The second gets the group name:

❯ getent group 100 | cut -d: -f1
users

and deletes it from the docker image.

This is to ensure that when creating our own user/group in the following command it'll work regardless of whether the user's UID/GID matches with existing users in the base docker image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dockerfile fails to build when UID/GID matches with the existing docker image user

2 participants