Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3de9c7a

Browse files
author
Takashi Matsuo
committed
ignore failure when creating a group
1 parent 30cc436 commit 3de9c7a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

.kokoro/docker/Dockerfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,19 @@ ARG GID=0
167167
ARG USERNAME=kbuilder
168168
ARG DOCKER_GID=999
169169

170-
# Allow access docker socker in the host.
171-
RUN groupadd -g ${DOCKER_GID} "host-docker"
172-
RUN groupadd -g ${GID} "${USERNAME}"
173-
RUN useradd -d /h -u ${UID} -g ${GID} ${USERNAME}
174-
RUN adduser "${USERNAME}" "host-docker"
170+
# Add a new user to the container image.
171+
# To allow access to the docker socket on the host, we use the docker
172+
# group on the host.
173+
174+
# First make sure the group exists. Ignore a failure in case
175+
# there is already a group with that id.
176+
RUN groupadd -g ${DOCKER_GID} "host-docker" | true
177+
178+
# Add a new user with the caller's uid and the docker goup id on the
179+
# host.
180+
RUN useradd -d /h -u ${UID} -g ${DOCKER_GID} ${USERNAME}
181+
182+
# Allow nopasswd sudo
175183
RUN echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
176184

177185
CMD ["python3.6"]

0 commit comments

Comments
 (0)