This repository has been archived by the owner on Jun 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup_dockertcp.sh
executable file
·74 lines (64 loc) · 1.9 KB
/
setup_dockertcp.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
#!/bin/bash
VERBOSE=false
while [ "$#" -gt 0 ]; do
case "$1" in
-v|--verbose)
VERBOSE=true
shift
;;
*)
echo "WARN: Unknown option: $1 ... but I'm continuing because crashing over a goofy param is stupid."
;;
esac
done
if [[ $EUID -ne 0 ]]; then
echo "ERR: This script must be run as root."
exit 1
fi
if [ ! -d "/etc/systemd" ]; then
echo "ERR: This system seems to not be managed by systemd"
exit 1
fi
if [ -e "/etc/docker/daemon.json" ]; then
if [ "$VERBOSE" = true ]; then
echo "Removing existing daemon.json"
fi
rm /etc/docker/daemon.json # too lazy to append
fi
if [ "$VERBOSE" = true ]; then
echo "Configuring Docker to run over TCP..."
echo "Adding values to Dockerd's daemon.json file"
fi
# use 127.0.0.1 instead of 0.0.0.0 to be more secure
echo '{"hosts": ["tcp://127.0.0.1:2375", "unix:///var/run/docker.sock"]}' > /etc/docker/daemon.json
if [ "$VERBOSE" = true ]; then
echo "Setting up systemd's override.conf for Docker"
fi
if [ ! -d "/etc/systemd/system/docker.service.d/" ]; then
if [ "$VERBOSE" = true ]; then
echo "Making docker.service.d directory"
fi
mkdir /etc/systemd/system/docker.service.d/
fi
if [ -e "/etc/systemd/system/docker.service.d/override.conf" ]; then
if [ "$VERBOSE" = true ]; then
echo "Removing existing override.conf"
fi
rm /etc/systemd/system/docker.service.d/override.conf
fi
touch /etc/systemd/system/docker.service.d/override.conf
if [ "$VERBOSE" = true ]; then
echo "Writing configuration to override.conf"
fi
echo "[Service]
ExecStart=
ExecStart=/usr/bin/dockerd" > /etc/systemd/system/docker.service.d/override.conf
if [ "$VERBOSE" = true ]; then
echo "Reloading systemd daemon"
fi
systemctl daemon-reload
if [ "$VERBOSE" = true ]; then
echo "Restarting Docker service"
fi
systemctl restart docker.service
echo "Docker should be set up over TCP. Check for any errors here if it doesn't work."