|
69 | 69 | echo User namespace remapping not configured.
|
70 | 70 | fi
|
71 | 71 |
|
| 72 | +# One day we can auto-detect whether the instance is v4-only, dualstack or v6-only. To avoid a |
| 73 | +# breaking change though, we'll default to ipv4 only and users can opt into v6 support. The elastic |
| 74 | +# stack has always defaulted to v4-only so this ensuring no breaking behaviour. |
| 75 | +# v6-only is currently not an option because docker doesn't support it, but maybe one day.... |
| 76 | +echo Customising docker network configuration... |
| 77 | + |
| 78 | +if [[ "${DOCKER_NETWORKING_PROTOCOL}" == "ipv4" ]]; then |
| 79 | + # This is the default |
| 80 | + cat <<<"$( |
| 81 | + jq \ |
| 82 | + '."default-address-pools"=[{"base":"172.17.0.0/12","size":20},{"base":"192.168.0.0/16","size":24}]' \ |
| 83 | + /etc/docker/daemon.json |
| 84 | + )" >/etc/docker/daemon.json |
| 85 | +elif [[ "${DOCKER_NETWORKING_PROTOCOL}" == "dualstack" ]]; then |
| 86 | + # Using v6 inside containers requires DOCKER_EXPERIMENTAL. This is configured |
| 87 | + # further down |
| 88 | + DOCKER_EXPERIMENTAL=true |
| 89 | + cat <<<"$(jq '.ipv6=true' /etc/docker/daemon.json)" >/etc/docker/daemon.json |
| 90 | + cat <<<"$(jq '."fixed-cidr-v6"="2001:db8:1::/64"' /etc/docker/daemon.json)" >/etc/docker/daemon.json |
| 91 | + cat <<<"$(jq '.ip6tables=true' /etc/docker/daemon.json)" >/etc/docker/daemon.json |
| 92 | + cat <<<"$( |
| 93 | + jq \ |
| 94 | + '."default-address-pools"=[{"base":"172.17.0.0/12","size":20},{"base":"192.168.0.0/16","size":24},{"base":"2001:db8:2::/104","size":112}]' \ |
| 95 | + /etc/docker/daemon.json |
| 96 | + )" >/etc/docker/daemon.json |
| 97 | +else |
| 98 | + # docker 25.0 doesn't support ipv6 only, so we don't support it either |
| 99 | + true |
| 100 | +fi |
| 101 | + |
72 | 102 | if [[ "${DOCKER_EXPERIMENTAL:-false}" == "true" ]]; then
|
73 | 103 | echo Configuring experiment flag for docker daemon...
|
74 | 104 | cat <<<"$(jq '.experimental=true' /etc/docker/daemon.json)" >/etc/docker/daemon.json
|
|
85 | 115 | echo Instance storage not configured.
|
86 | 116 | fi
|
87 | 117 |
|
88 |
| -echo Customising docker IP address pools... |
89 |
| -cat <<<"$( |
90 |
| - jq \ |
91 |
| - '."default-address-pools"=[{"base":"172.17.0.0/12","size":20},{"base":"192.168.0.0/16","size":24}]' \ |
92 |
| - /etc/docker/daemon.json |
93 |
| -)" >/etc/docker/daemon.json |
94 |
| - |
95 | 118 | echo Cleaning up docker images...
|
96 | 119 | systemctl start docker-low-disk-gc.service
|
97 | 120 |
|
|
0 commit comments