-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_docker.sh
executable file
·80 lines (63 loc) · 2.12 KB
/
install_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
#!/bin/bash
set +e
: '
Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Rafael Sene <[email protected]>
'
if (( $EUID != 0 )); then
echo "Please run as root"
exit
fi
# Remove any old Docker setup
apt-get remove docker docker-engine docker.io -y
# Common Update
apt-get update -y
# Install the repository
apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common -y
# Add Docker GPG Key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
apt-key fingerprint 0EBFCD88
ARCH=$(uname -m)
if [ "$ARCH" == "ppc64le" ]; then
add-apt-repository \
"deb [arch=ppc64el] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
fi
if [ "$ARCH" == "amd64" ] || [ "$ARCH" == "x86_64" ]; then
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
fi
if [ "$ARCH" == "s390x" ]; then
add-apt-repository \
"deb [arch=s390x] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
fi
# Common Update
apt-get update -y
# Install Docker
apt-get install docker-ce -y
# Enable Docker service
systemctl enable docker
# Enabling Docker Remote API on Ubuntu 16.04
# TODO this line is added everytime the script is ran causing the daemon to sometimes fail
sed -i -- 's/ExecStart=\/usr\/bin\/dockerd -H fd:\/\//ExecStart=\/usr\/bin\/dockerd -H fd:\/\/ -H tcp:\/\/0.0.0.0:4243/g' /lib/systemd/system/docker.service
systemctl daemon-reload
service docker restart
curl http://localhost:4243/version