Fix default installer to make local cluster pull images from docker proxy 22/13522/7
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 8 Jun 2023 08:43:33 +0000 (10:43 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 6 May 2024 10:58:08 +0000 (12:58 +0200)
Change-Id: I8de15cdce32ed2632d9ab8d5cf9a8147c20b2833
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
installers/install_docker_ce.sh

index 9d6387f..750cdb3 100755 (executable)
@@ -70,6 +70,15 @@ EOF"
         sudo service docker restart
         echo "... restarted Docker service again"
     fi
+
+    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 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"
     echo "... Docker CE installation done"