aboutsummaryrefslogtreecommitdiff
path: root/src/docker-in-docker
diff options
context:
space:
mode:
authorSamruddhi Khandale <skhandale@microsoft.com>2023-03-09 02:30:59 +0300
committerGitHub <noreply@github.com>2023-03-09 02:30:59 +0300
commitde1e634a6755e10b27e52ad4e0aa44f025540074 (patch)
tree5e3b4365a10465e9e0dfb3549fc64e996a1e73fc /src/docker-in-docker
parentfe449253f138f3c028627d3e9cc3d500d650b159 (diff)
Docker fix - BuildKit is enabled but the buildx component is missing or broken (#478)feature_docker-outside-of-docker_1.1.0feature_docker-in-docker_2.1.0
* Docker fix - BuildKit is enabled but the buildx component is missing or broken * nit * fix test
Diffstat (limited to 'src/docker-in-docker')
-rw-r--r--src/docker-in-docker/devcontainer-feature.json7
-rwxr-xr-xsrc/docker-in-docker/install.sh32
2 files changed, 28 insertions, 11 deletions
diff --git a/src/docker-in-docker/devcontainer-feature.json b/src/docker-in-docker/devcontainer-feature.json
index 58c2d14..798b8e8 100644
--- a/src/docker-in-docker/devcontainer-feature.json
+++ b/src/docker-in-docker/devcontainer-feature.json
@@ -1,6 +1,6 @@
{
"id": "docker-in-docker",
- "version": "2.0.1",
+ "version": "2.1.0",
"name": "Docker (Docker-in-Docker)",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/docker-in-docker",
"description": "Create child containers *inside* a container, independent from the host's docker instance. Installs Docker extension in the container along with needed CLIs.",
@@ -39,6 +39,11 @@
"default": "",
"proposals": [],
"description": "Define default address pools for Docker networks. e.g. base=192.168.0.0/16,size=24"
+ },
+ "installDockerBuildx": {
+ "type": "boolean",
+ "default": true,
+ "description": "Install Docker Buildx"
}
},
"entrypoint": "/usr/local/share/docker-init.sh",
diff --git a/src/docker-in-docker/install.sh b/src/docker-in-docker/install.sh
index dff1139..7705199 100755
--- a/src/docker-in-docker/install.sh
+++ b/src/docker-in-docker/install.sh
@@ -13,10 +13,8 @@ USE_MOBY="${MOBY:-"true"}"
DOCKER_DASH_COMPOSE_VERSION="${DOCKERDASHCOMPOSEVERSION:-"v1"}" # v1 or v2
AZURE_DNS_AUTO_DETECTION="${AZUREDNSAUTODETECTION:-"true"}"
DOCKER_DEFAULT_ADDRESS_POOL="${DOCKERDEFAULTADDRESSPOOL}"
-
-ENABLE_NONROOT_DOCKER="${ENABLE_NONROOT_DOCKER:-"true"}"
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
-
+INSTALL_DOCKER_BUILDX="${INSTALLDOCKERBUILDX:-"true"}"
MICROSOFT_GPG_KEYS_URI="https://packages.microsoft.com/keys/microsoft.asc"
DOCKER_MOBY_ARCHIVE_VERSION_CODENAMES="buster bullseye bionic focal jammy"
DOCKER_LICENSED_ARCHIVE_VERSION_CODENAMES="buster bullseye bionic focal hirsute impish jammy"
@@ -158,7 +156,7 @@ else
fi
# Install dependencies
-check_packages apt-transport-https curl ca-certificates pigz iptables gnupg2 dirmngr
+check_packages apt-transport-https curl ca-certificates pigz iptables gnupg2 dirmngr wget
if ! type git > /dev/null 2>&1; then
check_packages git
fi
@@ -307,13 +305,27 @@ if [ -f "/usr/local/share/docker-init.sh" ]; then
fi
echo "docker-init doesn't exist, adding..."
-# Add user to the docker group
-if [ "${ENABLE_NONROOT_DOCKER}" = "true" ]; then
- if ! getent group docker > /dev/null 2>&1; then
- groupadd docker
- fi
+if ! cat /etc/group | grep -e "^docker:" > /dev/null 2>&1; then
+ groupadd -r docker
+fi
+
+usermod -aG docker ${USERNAME}
+
+if [ "${INSTALL_DOCKER_BUILDX}" = "true" ]; then
+ buildx_version="latest"
+ find_version_from_git_tags buildx_version "https://github.com/docker/buildx" "refs/tags/v"
+
+ echo "(*) Installing buildx ${buildx_version}..."
+ buildx_file_name="buildx-v${buildx_version}.linux-${architecture}"
+ cd /tmp && wget "https://github.com/docker/buildx/releases/download/v${buildx_version}/${buildx_file_name}"
+
+ mkdir -p ${_REMOTE_USER_HOME}/.docker/cli-plugins
+ mv ${buildx_file_name} ${_REMOTE_USER_HOME}/.docker/cli-plugins/docker-buildx
+ chmod +x ${_REMOTE_USER_HOME}/.docker/cli-plugins/docker-buildx
- usermod -aG docker ${USERNAME}
+ chown -R "${USERNAME}:docker" "${_REMOTE_USER_HOME}/.docker"
+ chmod -R g+r+w "${_REMOTE_USER_HOME}/.docker"
+ find "${_REMOTE_USER_HOME}/.docker" -type d -print0 | xargs -n 1 -0 chmod g+s
fi
tee /usr/local/share/docker-init.sh > /dev/null \