-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdocker.sh
executable file
·93 lines (74 loc) · 2.5 KB
/
docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
# Copyright (c) 2018 Jegathesan Shanmugam
# Released under the MIT License (MIT)
# https://github.com/nullbyte91/Simple-Sh-DataScience/blob/master/LICENSE.md
# Title : docker.sh
# Description : This script help you to install docker on ubuntu 16.04
# author : Jegathesan Shanmugam
docker="docker"
dockerengine="docker-engine"
dockerio="docker.io"
aptTransportHttps="apt-transport-https"
caCertificates="ca-certificates"
curl="curl"
softwarePropertiesCommon="software-properties-common"
dockerCe="docker-ce"
fDocker="/etc/default/docker"
dDocker="/etc/systemd/system/docker.service.d/"
fhtt="http-proxy.conf"
#MainStartsHere
source ./helper_function.sh
# Remove old version
removeAptPackages ${docker}
removeAptPackages ${dockerengine}
removeAptPackages ${dockerio}
#Basic system update
systemBasicUpdates
#Install basic dep
installAptPackages ${aptTransportHttps}
installAptPackages ${caCertificates}
installAptPackages ${curl}
installAptPackages ${softwarePropertiesCommon}
#Add Docker official GPG Key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#Check Key fingerPrint
sudo apt-key fingerprint 0EBFCD88
#Setup stable repo of docker
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
#Basic system update
systemBasicUpdates
#Install docker
installAptPackages ${dockerCe}
read -r -p "Are you behind corporate proxy[Y/n]" response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
if [ ! -f ${fDocker} ]; then
echo "File not found. Creating it"
fi
echo "Creating a /etc/default/docker file"
sudo touch /etc/default/docker
read -r -p "DNS Address?" DNSAddress
echo "DOCKER_OPTS="- - dns ${DNSAddress}"" | sudo tee --append /etc/default/docker
echo "Creating a service file for docker"
sudo mkdir -p ${dDocker}
sudo touch ${dDocker}/${fhtt}
read -r -p "Proxy Address?" ProxyAddress
echo "[Service]
Environment="HTTP_PROXY=${ProxyAddress}"
Environment="HTTPS_PROXY=${ProxyAddress}"
" | sudo tee --append ${dDocker}/${fhtt}
fi
#Verify that Docker CE is installed correctly by running the hello-world image
sudo docker run hello-world
read -r -p "Add your user to the docker group[Y/n]" response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
sudo usermod -aG docker $USER
fi
echo "checking docker without sudo"
echo "running docker run hello-world"
docker run hello-world
echo "Docker install and configuration is done............"