forked from xkszltl/Roaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_conf.sh
executable file
·63 lines (49 loc) · 3.11 KB
/
docker_conf.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
#!/bin/bash
set -e
sudo echo 'Permission granted.'
export ROOT_DIR="$(readlink -e "$(dirname "$0")")"
cd "$ROOT_DIR"
. pkgs/env/cred.sh
echo '========================================'
echo '| HTTP Proxy'
echo '========================================'
sudo mkdir -p '/etc/systemd/system/docker.service.d'
echo "# This file is auto-generated and may be overwritten.
[Service]
Environment=\"HTTP_PROXY=$CRED_USR_PRIVOXY_ADDR:$CRED_USR_PRIVOXY_PORT\"
Environment=\"HTTPS_PROXY=$CRED_USR_PRIVOXY_ADDR:$CRED_USR_PRIVOXY_PORT\"
Environment=\"NO_PROXY=127.0.0.1,::1,localhost,docker.codingcafe.org,git.codingcafe.org\"
" | sudo tee '/etc/systemd/system/docker.service.d/http-proxy.conf'
sudo systemctl daemon-reload || true
# sudo systemctl restart docker
echo '========================================'
echo '| Daemon JSON (Before)'
echo '========================================'
sudo [ -e '/etc/docker/daemon.json' ] || sudo echo '{}' > '/etc/docker/daemon.json'
sudo cat '/etc/docker/daemon.json' | sudo tee '/etc/docker/daemon.json.bak' | jq -e '.'
echo '========================================'
echo '| Daemon JSON (After)'
echo '========================================'
sudo cat '/etc/docker/daemon.json.bak' \
| jq -e '. |= . + {"data-root":"/media/Scratch/docker"}' \
| jq -e '. |= . + {"default-runtime":"nvidia"}' \
| jq -e '. |= . + {"experimental":true}' \
| jq -e '. |= . + {"features":{}}' \
| jq -e '."features" |= ."features" + {"buildkit":true}' \
| jq -e '. |= . + {"max-concurrent-downloads":1024}' \
| jq -e '. |= . + {"max-concurrent-uploads":1024}' \
| jq -e '. |= . + {"storage-driver":"devicemapper"}' \
| jq -e '. |= . + {"storage-opts":[]}' \
| jq -e '."storage-opts"[."storage-opts" | length] |= . + "dm.thinpooldev=/dev/mapper/Mocha-docker--pool"' \
| jq -e '."storage-opts"[."storage-opts" | length] |= . + "dm.use_deferred_removal=true"' \
| jq -e '."storage-opts"[."storage-opts" | length] |= . + "dm.use_deferred_deletion=true"' \
| jq -e '. |= . + {"storage-driver":"overlay2"}' \
| jq -e '. |= . + {"storage-opts":[]}' \
| sudo tee '/etc/docker/daemon.json' | jq -e '.' \
|| ( set -e
sudo cat '/etc/docker/daemon.json.bak' > '/etc/docker/daemon.json'
false
)
echo '========================================'
echo '| Done. Please restart docker daemon.'
echo '========================================'