aboutsummaryrefslogtreecommitdiff
path: root/src/docker-in-docker/install.sh
diff options
context:
space:
mode:
authorSamruddhi Khandale <skhandale@microsoft.com>2023-09-29 22:02:54 +0300
committerGitHub <noreply@github.com>2023-09-29 22:02:54 +0300
commit04cb7d1e797a81ce00450aa1174fff8f74b3ac12 (patch)
tree9f44d76038c9cbff96fa6c788437af5f9e1650c7 /src/docker-in-docker/install.sh
parentcf92754bf4535ac3344a6b5c5d444dc16e9922cb (diff)
Docker-in-docker: Updates docker-init with "pkill" (#711)feature_docker-in-docker_2.6.0
* Docker-in-docker: Updates docker-init with "pkill" * pkill only if container didn't start at first * pkill with condition * add back sudo_if
Diffstat (limited to 'src/docker-in-docker/install.sh')
-rwxr-xr-xsrc/docker-in-docker/install.sh15
1 files changed, 14 insertions, 1 deletions
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`