Skip to content

Commit e5d6489

Browse files
committed
docker script added: Install docker and configure proxy if your behind proxy
1 parent a387a5a commit e5d6489

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

Diff for: docker.sh

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

0 commit comments

Comments
 (0)