-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerman.sh
executable file
·55 lines (40 loc) · 1.49 KB
/
dockerman.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
#!/usr/bin/env bash
#
# One-click installation script for Docker and Docker Compose
# Should work on sh, dash, bash, ksh, zsh
#
# Copyright (C) 2018-present, Implemented by Bin Hua<https://github.com/tourcoder>
red='\e[91m'
none='\e[0m'
# Check Root permissions
[[ $(id -u) != 0 ]] && echo -e "\n ${red}Sorry, please use root permissions\n ${none}" && exit 1
# Check supported OS
if [[ $(command -v apt-get) || $(command -v yum) ]] && [[ $(command -v systemctl) ]]; then
if ! [ $(command -v docker) ]; then
# Install Docker
curl -sSL https://get.docker.com/ | sh
fi
if ! [ $(command -v docker-compose) ]; then
# Get latest docker compose version number
get_latest_release() {
curl --silent "https://api.github.com/repos/docker/compose/releases/latest" |
grep '"tag_name":' |
sed -E 's/.*"([^"]+)".*/\1/'
}
# Install Docker compose
curl -L https://github.com/docker/compose/releases/download/`get_latest_release`/docker-compose-`uname -s`-`uname -m` -o /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose
fi
else
echo -e "\n ${red}Sorry, unsupported OS\n ${none}" && exit 1
fi
# Start Docker
service docker start
echo "*************************************************"
# Check Docker version
docker version
echo "*************************************************"
# Check Docker-compose version
docker-compose version
echo "*************************************************"
exit 1