-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall-docker.sh
executable file
·72 lines (62 loc) · 2.37 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
#
# 安裝 docker and docker-compose
#
#!/bin/bash
# 顯示說明
clear
echo "//////////////////////////////////////////////////"
echo "此步驟將安裝 Docker 與 docker-compose"
echo "請以可 sudo 之帳號進行"
echo "若已安裝過則請跳過此步驟"
echo "//////////////////////////////////////////////////"
echo ""
read -p "是否繼續?(預設: Y)[Y/n] " value
if [[ "${value}" != "n" ]] && [[ "${value}" != "N" ]]; then
# docker_compose_version="1.23.1"
lsb_dist=""
# Every system that we officially support has /etc/os-release
if [ -r /etc/os-release ]; then
lsb_dist="$(. /etc/os-release && echo "$ID")"
fi
# install docker
echo "**** 安裝 Docker ****"
sleep 3
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh
printf "\n\n"
printf "**** 執行 usermod -aG docker $(whoami) ****\n\n"
sudo usermod -aG docker $(whoami)
sleep 3
# install docker-compose
echo "**** 安裝 docker-compose ****"
sleep 3
compose_version=$(curl https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
echo ">>>> docker-compose 版本: ${compose_version}"
output='/usr/local/bin/docker-compose'
sudo curl -L https://github.com/docker/compose/releases/download/$compose_version/docker-compose-$(uname -s)-$(uname -m) -o $output
sudo chmod +x $output
echo $(docker-compose --version)
printf "\n\n"
# echo "**** 安裝 docker-compose ${docker_compose_version} ****"
# sleep 3
# curl -L https://github.com/docker/compose/releases/download/${docker_compose_version}/docker-compose-`uname -s`-`uname -m` -o docker-compose
# sudo mv docker-compose /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose
if [ "$lsb_dist" == "centos" ]; then
echo "**** CentOS 啟用 docker daemon ****"
sleep 3
sudo systemctl enable docker
sleep 3
sudo systemctl start docker
fi
echo "**** Docker 與 docker-compose 安裝完成 ****"
printf "\n"
#echo "**** 建議重新登入以使權限生效 ****"
#echo "**** 若未完成後續步驟,重新登入後請執行以下指令繼續 ****"
#echo " cd ${PWD}"
#echo " ./install.sh"
#echo "**** 重新登入後可執行以下指令查看版本: ****"
#echo " docker version"
#echo " docker-compose version"
#printf "\n"
fi