blob: e4207f2e8826837800f5864e665cd0bd54efcff4 [file] [log] [blame]
Samuli Silvius747a8e22019-03-29 13:20:28 +02001FROM quay.io/ansible/molecule:2.20
2
3ARG USER_ID
4ARG GROUP_ID
5ARG DOCKER_GROUP_ID
6
7# When user/group provided, create user to have matching ids (for the host user)
8# to avoid this docker writing files as root owned
9RUN if [ ${USER_ID:-0} -ne 0 ] && [ ${GROUP_ID:-0} -ne 0 ]; then \
10 # shadow needed for addgroup
11 # sshpass needed for accessing docker_host (localhost) with ssh and without password prompt
12 apk --no-cache add shadow sshpass && \
13 addgroup -g ${GROUP_ID} molecule && \
14 adduser -D -u ${USER_ID} -G molecule molecule && \
15 # Add user to same docker group as in docker_host to be able to use docker driver as sudo
16 groupadd docker-host -g ${DOCKER_GROUP_ID} && \
17 usermod -aG ${DOCKER_GROUP_ID} molecule \
18;fi
19
20USER molecule