forked from rkoyama1623-2021/setup_my_environment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_docker.sh
78 lines (65 loc) · 2.46 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
#!/usr/bin/env bash
SUDO='sudo -E'
YES='-y --allow-unauthenticated'
APT='apt-get'
function linux_remove_old_docker () {
${SUDO} ${APT} remove docker docker-engine docker.io containerd runc
}
function linux_setup_repository () {
${SUDO} ${APT} update
${SUDO} ${APT} install apt-transport-https ca-certificates curl gnupg lsb-releas
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | ${SUDO} gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
}
function linux_install_docker_engine() {
${SUDO} ${APT} update
${SUDO} ${APT} install docker-ce docker-ce-cli containerd.io
}
function mac_install_docker_engine() {
# brew install docker docker-compose docker-machine xhyve docker-machine-driver-xhyve
# brew install docker docker-machine
# sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
# sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
# docker-machine create default --driver xhyve --xhyve-experimental-nfs-share
# https://dhwaneetbhatt.com/blog/run-docker-without-docker-desktop-on-macos
# minikube is used to run a Kubernetes cluster on local environment.
# Install hyperkit and minikube
brew install hyperkit
brew install minikube
# Install Docker CLI
brew install docker
brew install docker-compose
# Start minikube
minikube start
# Tell Docker CLI to talk to minikube's VM
if ! grep 'eval $(minikube docker-env)' ~/.zshrc; then
echo 'eval $(minikube docker-env)' >> ~/.zshrc;
fi
# Save IP to a hostname
echo "`minikube ip` docker.local" | sudo tee -a /etc/hosts > /dev/null
# # Test
# docker run hello-world
}
function main() {
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*)
machine=Linux;
linux_remove_old_docker;
linux_setup_repository;
linux_install_docker_engine;
;;
Darwin*)
machine=Mac;
mac_install_docker_engine;
;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
MSYS_NT*) machine=Git;;
*) machine="UNKNOWN:${unameOut}"
esac
}
# main
main