forked from realestate-com-au/intro-to-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·82 lines (67 loc) · 1.44 KB
/
setup.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
81
82
#! /bin/bash
yay() {
echo -ne "\033[32mYAY: \033[0m"; echo "$1"
}
boo() {
(echo -ne "\033[31mBOO: \033[0m"; echo "$1") >&2
exit 1
}
beat() {
echo ""
}
docker_sock=/var/run/docker.sock
if test -n "$DOCKER_HOST"; then
yay "\$DOCKER_HOST is set"
docker_addr=$(echo $DOCKER_HOST | sed -e 's|tcp://\(.*\):[0-9]*|\1|')
elif test -e $docker_sock; then
yay "$docker_sock exists"
docker_addr=localhost
else
boo "No \$DOCKER_HOST, no $docker_sock ... where's Docker?"
fi
if docker info > /dev/null; then
yay "I can talk to docker"
else
boo "I can't talk to docker"
fi
beat
echo "Docker is at $docker_addr"
beat
version_of() {
$1 --version | egrep -o '\d+(\.\d+)+'
}
version_lte() {
[ "$1" = "`echo -e "$1\n$2" | docker run -i ubuntu:14.04 sort -V | head -n1`" ]
}
check_version() {
app=$1
expected_version=$2
actual_version=$(version_of $app)
if version_lte $expected_version $actual_version; then
yay "$app version $actual_version"
else
boo "need $app version $expected_version, got $actual_version"
fi
}
check_version docker 1.11.0
check_version docker-compose 1.7.0
beat
pull() {
echo ""
echo "=== $1"
docker pull $1
}
echo "Pulling some images to get you started ..."
pull alpine
pull busybox
pull centos
pull ubuntu
pull ubuntu:14.04
pull ubuntu:16.04
pull microsoft/dotnet:1.0.0-preview1
pull node:5.11.0-slim
pull node:6.2.2
pull python:2.7-alpine
pull ruby:2.3
pull realestate/ciao
pull realestate/ciao-proxy