Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cirolosapio committed Sep 25, 2023
1 parent db572f2 commit a7adc64
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/alpine-docker/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"name": "alpine-docker",
"id": "alpine-docker",
"version": "0.0.4",
"version": "0.0.5",
"description": "Installs docker and docker-compose on alpine",
"documentationURL": "https://github.com/cirolosapio/devcontainers-features/tree/main/src/alpine-docker",
"options": {
"hostDockerGid": {
"type": "string",
"description": "Docker group id on the host machine (retrieve with \"getent group docker | cut -d: -f3\""
},
"installDockerCompose": {
"type": "boolean",
"default": false,
Expand Down
16 changes: 16 additions & 0 deletions src/alpine-docker/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ echo "Activating feature 'alpine-docker'"

apk add --no-cache docker

CURRENT_USER=$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)
echo "CURRENT_USER is $CURRENT_USER"
echo "HOST_DOCKER_GID is $HOSTDOCKERGID"

HOST_DOCKER_GROUP=$(getent group $HOSTDOCKERGID | cut -d: -f1)

if [[ -z $HOST_DOCKER_GROUP ]]; then
echo "HOST_DOCKER_GROUP is empty, creating new group 'host-docker'"
addgroup -g $HOSTDOCKERGID host-docker
HOST_DOCKER_GROUP=host-docker
else
echo "HOST_DOCKER_GROUP is already used, using existing group '$HOST_DOCKER_GROUP'"
fi

addgroup $CURRENT_USER $HOST_DOCKER_GROUP

if [[ $INSTALLDOCKERCOMPOSE == "true" ]]; then
apk add --no-cache docker-compose
fi
Expand Down

0 comments on commit a7adc64

Please sign in to comment.