Fix containerd configuration to be applied only if there is docker proxy 19/13519/1
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Wed, 7 Jun 2023 21:19:00 +0000 (23:19 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Wed, 7 Jun 2023 21:19:15 +0000 (23:19 +0200)
Change-Id: I483a916d9aa341af9184a3e549f7cf9409d4744b
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
installers/install_docker_ce.sh

index 64c23c2..5c0cc6d 100755 (executable)
@@ -90,12 +90,14 @@ EOF"
         echo "... restarted Docker service again"
     fi
 
-    echo "Configuring containerd"
-    sudo mv /etc/containerd/config.toml /etc/containerd/config.toml.orig 2>/dev/null
-    sudo bash -c "containerd config default > /etc/containerd/config.toml"
-    sudo sed -i "s#\[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors\]#\[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors\]\n        \[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"docker.io\"\]\n          endpoint = \[\"${DOCKER_PROXY_URL}\"\]\n        \[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"registry.hub.docker.com\"]\n          endpoint = \[\"${DOCKER_PROXY_URL}\"]#" /etc/containerd/config.toml
-    sudo diff /etc/containerd/config.toml.orig /etc/containerd/config.toml
-    sudo service containerd restart
+    if [ -n "${DOCKER_PROXY_URL}" ]; then
+        echo "Configuring containerd"
+        sudo mv /etc/containerd/config.toml /etc/containerd/config.toml.orig 2>/dev/null
+        sudo bash -c "containerd config default > /etc/containerd/config.toml"
+        sudo sed -i "s#\[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors\]#\[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors\]\n        \[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"docker.io\"\]\n          endpoint = \[\"${DOCKER_PROXY_URL}\"\]\n        \[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"registry.hub.docker.com\"]\n          endpoint = \[\"${DOCKER_PROXY_URL}\"]#" /etc/containerd/config.toml
+        sudo diff /etc/containerd/config.toml.orig /etc/containerd/config.toml
+        sudo service containerd restart
+    fi
 
     [ -z "${DEBUG_INSTALL}" ] || ! echo "File: /etc/docker/daemon.json" || cat /etc/docker/daemon.json
     sg docker -c "docker version" || FATAL "Docker installation failed"