forked from dmandalidis/docker-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.sh
executable file
·59 lines (47 loc) · 1.73 KB
/
.travis.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
#!/bin/bash
set -e
if [[ -z $1 ]]; then
"I need a command!"
exit 1
fi
case "$1" in
install_docker)
if [[ -z $DOCKER_VERSION ]]; then
echo "DOCKER_VERSION needs to be set as an environment variable"
exit 1
fi
# TODO detect which docker version is already installed and skip
# uninstall/reinstall if it matches $DOCKER_VERSION
sudo systemctl stop docker || :
sudo rm -fr /var/lib/docker || :
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get -qq update
sudo apt-get -qq remove --purge docker docker-engine docker.io containerd runc
sudo mkdir -p /etc/systemd/system/docker.service.d/
sudo cp exec-override.conf /etc/systemd/system/docker.service.d/exec-override.conf
sudo systemctl daemon-reload
sudo rm -rf /etc/docker
sudo rm -rf /etc/default/docker
PACKAGE_VERSION=$(sudo apt-cache madison docker-ce | grep $DOCKER_VERSION | cut -f2 -d"|" | tr -d '[:space:]')
if [[ -z $PACKAGE_VERSION ]]; then
echo "No candidate package with $DOCKER_VERSION was found";
exit 1;
fi
sudo apt-get -q -y install docker-ce=$PACKAGE_VERSION
sudo docker info
sudo docker swarm init --advertise-addr 127.0.0.1
sudo echo ${DOCKER_PASSWORD} | docker login --username ${DOCKER_USER} --password-stdin
;;
dump_docker_config)
echo "Contents of /etc/docker/daemon.json:"
sudo cat /etc/docker/daemon.json || :
echo "Service status"
sudo systemctl -l status docker --no-pager
echo "Service logs"
sudo journalctl -u docker --no-pager
;;
*)
echo "Unknown command $1"
exit 2
esac