...

Text file src/github.com/GoogleCloudPlatform/k8s-config-connector/scripts/environment-setup/docker-setup.sh

Documentation: github.com/GoogleCloudPlatform/k8s-config-connector/scripts/environment-setup

     1#!/bin/bash
     2# Copyright 2022 Google LLC
     3#
     4# Licensed under the Apache License, Version 2.0 (the "License");
     5# you may not use this file except in compliance with the License.
     6# You may obtain a copy of the License at
     7#
     8#      http://www.apache.org/licenses/LICENSE-2.0
     9#
    10# Unless required by applicable law or agreed to in writing, software
    11# distributed under the License is distributed on an "AS IS" BASIS,
    12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13# See the License for the specific language governing permissions and
    14# limitations under the License.
    15
    16sudo apt remove docker-engine docker-runc docker-containerd
    17
    18set -o errexit
    19
    20sudo mkdir -p /etc/apt/keyrings
    21OS_ID=$(cat /etc/os-release | grep -oP "^ID=\K.*")
    22curl -fsSL https://download.docker.com/linux/${OS_ID}/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    23echo \
    24  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/${OS_ID} \
    25  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    26
    27sudo apt-get update
    28sudo apt-get install docker-ce
    29
    30sudo service docker stop
    31sudo ip link set docker0 down
    32sudo ip link del docker0
    33
    34cat <<EOF | sudo tee /etc/docker/daemon.json
    35{
    36  "data-root": "/usr/local/google/docker",
    37  "bip": "192.168.9.1/24",
    38  "default-address-pools": [
    39    {
    40      "base": "192.168.11.0/22",
    41      "size": 24
    42    }
    43  ],
    44  "storage-driver": "overlay2",
    45  "debug": true,
    46  "registry-mirrors": ["https://mirror.gcr.io"]
    47}
    48EOF
    49
    50sudo service docker start
    51
    52set +e
    53sudo addgroup docker
    54sudo adduser $USER docker
    55set -e
    56
    57GREEN='\033[0;32m'
    58NC='\033[0m'
    59echo -e "${GREEN}DOCKER SETUP SUCCESSFUL${NC}"

View as plain text