diff --git a/README.md b/README.md index 77d15e92..165ab84d 100644 --- a/README.md +++ b/README.md @@ -329,6 +329,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **06.07.26:** - Fall back to ipv4 bind address when ipv6 is disabled in the kernel. * **17.05.26:** - Let server listen on both ipv4 and ipv6 even when running container as root. * **10.08.25:** - Let server listen on both ipv4 and ipv6. * **03.06.25:** - Allow setting PWA name using env var `PWA_APPNAME`. diff --git a/readme-vars.yml b/readme-vars.yml index 3e4b7aa7..b89d2e21 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -102,6 +102,7 @@ init_diagram: | "code-server:latest" <- Base Images # changelog changelogs: + - {date: "06.07.26:", desc: "Fall back to ipv4 bind address when ipv6 is disabled in the kernel."} - {date: "17.05.26:", desc: "Let server listen on both ipv4 and ipv6 even when running container as root."} - {date: "10.08.25:", desc: "Let server listen on both ipv4 and ipv6."} - {date: "03.06.25:", desc: "Allow setting PWA name using env var `PWA_APPNAME`."} diff --git a/root/etc/s6-overlay/s6-rc.d/svc-code-server/run b/root/etc/s6-overlay/s6-rc.d/svc-code-server/run index 5e2ecba4..4e762267 100755 --- a/root/etc/s6-overlay/s6-rc.d/svc-code-server/run +++ b/root/etc/s6-overlay/s6-rc.d/svc-code-server/run @@ -18,12 +18,21 @@ if [[ -z ${PWA_APPNAME} ]]; then PWA_APPNAME="code-server" fi +# Bind to the IPv6 wildcard (dual-stack, also serves IPv4) when IPv6 is +# available, otherwise fall back to the IPv4 wildcard. Binding to "[::]" +# fails outright on hosts/containers where IPv6 is disabled. +if [[ -e /proc/net/if_inet6 ]]; then + BIND_ADDR="[::]:8443" +else + BIND_ADDR="0.0.0.0:8443" +fi + if [[ -z ${LSIO_NON_ROOT_USER} ]]; then exec \ s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 8443" \ s6-setuidgid abc \ /app/code-server/bin/code-server \ - --bind-addr "[::]:8443" \ + --bind-addr "${BIND_ADDR}" \ --user-data-dir /config/data \ --extensions-dir /config/extensions \ --disable-telemetry \