Skip to content

Commit e917f17

Browse files
committed
Make the listen address user configurable.
1 parent 733f78a commit e917f17

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ services:
118118
- PROXY_DOMAIN=code-server.my.domain #optional
119119
- DEFAULT_WORKSPACE=/config/workspace #optional
120120
- PWA_APPNAME=code-server #optional
121+
- BIND_ADDR="[::]:8443" #optional
121122
volumes:
122123
- /path/to/code-server/config:/config
123124
ports:
@@ -140,6 +141,7 @@ docker run -d \
140141
-e PROXY_DOMAIN=code-server.my.domain `#optional` \
141142
-e DEFAULT_WORKSPACE=/config/workspace `#optional` \
142143
-e PWA_APPNAME=code-server `#optional` \
144+
-e BIND_ADDR="[::]:8443" #optional
143145
-p 8443:8443 \
144146
-v /path/to/code-server/config:/config \
145147
--restart unless-stopped \
@@ -163,6 +165,7 @@ Containers are configured using parameters passed at runtime (such as those abov
163165
| `-e PROXY_DOMAIN=code-server.my.domain` | If this optional variable is set, this domain will be proxied for subdomain proxying. See [Documentation](https://github.com/coder/code-server/blob/main/docs/guide.md#using-a-subdomain) |
164166
| `-e DEFAULT_WORKSPACE=/config/workspace` | If this optional variable is set, code-server will open this directory by default |
165167
| `-e PWA_APPNAME=code-server` | If this optional variable is set, the PWA app will the specified name. |
168+
| `-e BIND_ADDR=[::]:8443` | If this optional variable is set, code-server will listen to this address instead of auto-detecting. |
166169
| `-v /config` | Contains all relevant configuration files. |
167170
| `--read-only=true` | Run container with a read-only filesystem. Please [read the docs](https://docs.linuxserver.io/misc/read-only/). |
168171
| `--user=1000:1000` | Run container with a non-root user. Please [read the docs](https://docs.linuxserver.io/misc/non-root/). |

root/etc/s6-overlay/s6-rc.d/svc-code-server/run

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ if [[ -z ${PWA_APPNAME} ]]; then
1818
PWA_APPNAME="code-server"
1919
fi
2020

21-
# Bind to the IPv6 wildcard (dual-stack, also serves IPv4) when IPv6 is
22-
# available, otherwise fall back to the IPv4 wildcard. Binding to "[::]"
23-
# fails outright on hosts/containers where IPv6 is disabled.
24-
if [[ -e /proc/net/if_inet6 ]]; then
25-
BIND_ADDR="[::]:8443"
26-
else
27-
BIND_ADDR="0.0.0.0:8443"
21+
if [[ -z ${BIND_ADDR} ]] ; then
22+
# Bind to the IPv6 wildcard (dual-stack, also serves IPv4) when IPv6 is
23+
# available, otherwise fall back to the IPv4 wildcard. Binding to "[::]"
24+
# fails outright on hosts/containers where IPv6 is disabled.
25+
if [[ -e /proc/net/if_inet6 ]]; then
26+
BIND_ADDR="[::]:8443"
27+
else
28+
BIND_ADDR="0.0.0.0:8443"
29+
fi
2830
fi
2931

3032
if [[ -z ${LSIO_NON_ROOT_USER} ]]; then

0 commit comments

Comments
 (0)