Ubuntu18.04 docker安装配置脚本

1. 前言

在近期的科研过程中需要在16个边缘计算节点上安装docker环境,模拟无人机上的资源调用与任务执行。记录一下docker的安装配置。

2. docker安装配置脚本

#!/bin/bash

#update the source
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

sudo echo "# aliyun sources" > /etc/apt/sources.list

sudo echo "deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" >> //etc/apt/sources.list
sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" >> /etc/apt/sources.list

sudo echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse" >> /etc/apt/sources.list
sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse" >> /etc/apt/sources.list

sudo echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse" >> /etc/apt/sources.list
sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse" >> /etc/apt/sources.list

sudo echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse" >> /etc/apt/sources.list
sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse" >> /etc/apt/sources.list

sudo echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse" >> /etc/apt/sources.list
sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse" >> /etc/apt/sources.list

sudo echo "" >> /etc/apt/sources.list

sudo apt-get update -y  

#install net-tools
sudo apt install -y net-tools

#install dependency package
sudo apt install -y apt-transport-https ca-certificates software-properties-common curl

#add GPG key
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

#add the source of docker
sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7EA0A9C3F273FCD8

sudo apt-get update

#install docker-ce
sudo apt install -y docker-ce
sudo apt install -y docker-ce

#config iso speed
sudo echo "{\"registry-mirrors\": [\"https://dockerhub.azk8s.cn\", \"https://reg-mirror.qiniu.com\", \"https://registry.docker-cn.com\"]}" > /etc/docker/daemon.json

#restart docker
sudo systemctl daemon-reload
sudo systemctl restart docker

#power on self-start docker-ce
sudo systemctl enable docker
sudo systemctl start docker

sudo docker version

#add users to docker
sudo groupadd docker
sudo gpasswd -a $USER docker
sudo gpasswd -a a docker
sudo newgrp docker

#load image
sudo docker load -i mysql.tar
sudo docker load -i tomcat.tar
sudo docker images

你可能感兴趣的:(Ubuntu18.04 docker安装配置脚本)