Correct Docker Proxy Syntax 57/10357/1
authorbeierlm <mark.beierl@canonical.com>
Fri, 19 Feb 2021 14:34:57 +0000 (09:34 -0500)
committerbeierlm <mark.beierl@canonical.com>
Fri, 19 Feb 2021 15:30:53 +0000 (16:30 +0100)
Updates the syntax for managing the docker proxy so we can avoid
the rate limit issue

Change-Id: I29f9da9f7b3af57dd1614ded595d463c4ef14f9e
Signed-off-by: beierlm <mark.beierl@canonical.com>
(cherry picked from commit 8ef389381688e96f1aba089e98342c94c4b4fb88)

installers/full_install_osm.sh

index a037854..ebf2e03 100755 (executable)
@@ -404,18 +404,18 @@ function install_docker_ce() {
         echo "Configuring docker proxy ..."
         if [ -f /etc/docker/daemon.json ]; then
             if grep -q registry-mirrors /etc/docker/daemon.json; then
-                sudo sed -Ei 's/("registry-mirrors".*\[)(.*)\]/\1\2, \"'"${DOCKER_PROXY_URL}"'\"\]/' /etc/docker/daemon.json
+                sudo sed -i "s|registry-mirrors.*|registry-mirrors\": [\"${DOCKER_PROXY_URL}\"] |" /etc/docker/daemon.json
             else
-                sudo sed -i 's/{/{\n  "registry-mirrors": [\"'"${DOCKER_PROXY_URL}"'\"]",/' /etc/docker/daemon.json
+                sudo sed -i "s|{|{\n  \"registry-mirrors\": [\"${DOCKER_PROXY_URL}\"],|" /etc/docker/daemon.json
             fi
         else
-            sudo cat << EOF > /etc/docker/daemon.json
+            sudo bash -c "cat << EOF > /etc/docker/daemon.json
 {
-  "registry-mirrors": ["${DOCKER_PROXY_URL}"]
+  \"registry-mirrors\": [\"${DOCKER_PROXY_URL}\"]
 }
-EOF
+EOF"
         fi
-       sudo systemctl daemon-reload
+        sudo systemctl daemon-reload
         sudo service docker restart
         echo "... restarted Docker service again"
     fi