fix(code-server): pass SERVICE_HOSTNAME as HOST so the zsh prompt shows the hostname

This commit is contained in:
tiennm99 committed 2026-10-06 11:11:39 +07:00
1 parent 088579890a
commit 56b1c5f931
3 files changed
+10 -2

No files matched your search

+1 -1
View File
@@ -10,6 +10,6 @@ PASSWORD=
GIT_NAME=
GIT_EMAIL=
# Container hostname, shown in the shell prompt.
# Container hostname, also passed in as HOST -- the name zsh's prompt shows.
# Not named HOSTNAME: the deploying shell's own HOSTNAME would override it.
SERVICE_HOSTNAME=code-server
+8 -1
View File
@@ -98,7 +98,7 @@ new binary overwrites the old one.
| --- | --- |
| `PASSWORD` | Web UI login. Required. |
| `GIT_NAME` / `GIT_EMAIL` | Git author and committer identity |
| `SERVICE_HOSTNAME` | Container hostname, and the name the shell prompt shows |
| `SERVICE_HOSTNAME` | Container hostname, and the name the shell prompt shows (also passed as `HOST`) |
Generate a password with `openssl rand -base64 24`.
@@ -109,6 +109,13 @@ can only read from inside the container.
The `coder` user has passwordless `sudo`, as the image sets it up. Anyone who
can log in to the editor is root in the container.
`SERVICE_HOSTNAME` is used twice: as the container's `hostname:` and as the
`HOST` variable inside it. Coolify injects `HOST=0.0.0.0` into every compose
app, and zsh seeds `$HOST` and the `%m`/`%M` prompt escapes from that variable
rather than calling `gethostname()`, so a zsh prompt reads `0`. code-server
itself never reads `HOST`; it binds through `--bind-addr`. bash is unaffected;
its `\h` uses the real hostname.
## Docker access
The host's Docker socket is bind-mounted at `/var/run/docker.sock`. The image
+1
View File
@@ -11,6 +11,7 @@ services:
- GIT_AUTHOR_EMAIL=${GIT_EMAIL}
- GIT_COMMITTER_NAME=${GIT_NAME}
- GIT_COMMITTER_EMAIL=${GIT_EMAIL}
- HOST=${SERVICE_HOSTNAME}
volumes:
- 'code-server-home:/home/coder'
- 'code-server-workspace:/workspace'