universal-docker: initial release

This commit is contained in:
aptalca
2020-10-23 12:03:41 -04:00
parent ca3be57894
commit 2f381e5872
7 changed files with 86 additions and 76 deletions
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/with-contenv bash
echo "**** installing docker and docker compose ****"
if [ -f /usr/bin/apt ]; then
DISTRONAME="ubuntu"
else
DISTRONAME="alpine"
fi
ARCH=$(uname -m)
if [ -f "/docker-compose-${DISTRONAME}/docker-compose_${ARCH}" ] ; then
echo "Copying over docker and docker-compose binaries"
mv "/docker-compose-${DISTRONAME}/docker-compose_${ARCH}" /usr/local/bin/docker-compose
mv "/docker-compose-${DISTRONAME}/docker_${ARCH}" /usr/local/bin/docker
chmod +x /usr/local/bin/docker-compose
rm -rf /docker-compose-ubuntu /docker-compose-alpine
else
echo "**** docker and docker-compose already installed, skipping ****"
fi
if [ -S /var/run/docker.sock ]; then
DOCKER_GID=$(stat -c '%g' "/var/run/docker.sock")
if id -G abc | grep -qw "$DOCKER_GID"; then
exit 0
else
DOCKER_NAME=$(getent group "${DOCKER_GID}" | awk -F: '{print $1}')
if [ -z "${DOCKER_NAME}" ]; then
DOCKER_NAME="dockergroup"
groupadd -g "${DOCKER_GID}" "${DOCKER_NAME}"
fi
usermod -aG "${DOCKER_NAME}" abc
fi
elif [ -n "$DOCKER_HOST" ]; then
echo "**** /var/run/docker.sock is not mapped, therefore, docker client will only work with a remote docker service ****"
else
echo "**** Please map /var/run/docker.sock for access to docker service on host. Alternatively you can manually define a remote host address with the docker cli option -H ****"
fi