aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/docker-in-docker/devcontainer-feature.json2
-rwxr-xr-xsrc/docker-in-docker/install.sh15
2 files changed, 15 insertions, 2 deletions
diff --git a/src/docker-in-docker/devcontainer-feature.json b/src/docker-in-docker/devcontainer-feature.json
index 2feea7d..c64c590 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.5.0",
+ "version": "2.6.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.",
diff --git a/src/docker-in-docker/install.sh b/src/docker-in-docker/install.sh
index 39d1b77..63dd567 100755
--- a/src/docker-in-docker/install.sh
+++ b/src/docker-in-docker/install.sh
@@ -362,8 +362,9 @@ EOF
tee -a /usr/local/share/docker-init.sh > /dev/null \
<< 'EOF'
dockerd_start="AZURE_DNS_AUTO_DETECTION=${AZURE_DNS_AUTO_DETECTION} DOCKER_DEFAULT_ADDRESS_POOL=${DOCKER_DEFAULT_ADDRESS_POOL} $(cat << 'INNEREOF'
+ # Stop dockerd and containerd in case they are already running
+ docker info > /dev/null 2>&1 && pkill dockerd && pkill containerd
# explicitly remove dockerd and containerd PID file to ensure that it can start properly if it was stopped uncleanly
- # ie: docker kill <ID>
find /run /var/run -iname 'docker*.pid' -delete || :
find /run /var/run -iname 'container*.pid' -delete || :
@@ -444,6 +445,16 @@ dockerd_start="AZURE_DNS_AUTO_DETECTION=${AZURE_DNS_AUTO_DETECTION} DOCKER_DEFAU
INNEREOF
)"
+sudo_if() {
+ COMMAND="$*"
+
+ if [ "$(id -u)" -ne 0 ]; then
+ sudo $COMMAND
+ else
+ $COMMAND
+ fi
+}
+
retry_docker_start_count=0
docker_ok="false"
@@ -469,6 +480,8 @@ do
if [ "${docker_ok}" != "true" ]; then
echo "(*) Failed to start docker, retrying..."
+ sudo_if pkill dockerd
+ sudo_if pkill containerd
fi
retry_docker_start_count=`expr $retry_docker_start_count + 1`