fix: show the container hostname in the shell prompt

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().
The prompt read "0", the first dot-separated field of 0.0.0.0, even though the
container hostname itself was set correctly.

Pass the hostname in as HOST alongside the hostname: key, both from a single
SERVICE_HOSTNAME variable. Neither service reads HOST itself -- code-server
binds [::]:8443, Paseo binds PASEO_LISTEN -- so this only affects the prompt.

Not named HOSTNAME: Compose interpolation lets the deploying shell's
environment win over the .env file, and HOSTNAME is set in every container,
including the one Coolify runs in.

PASEO_LABEL is renamed to SERVICE_HOSTNAME; it was never a Paseo variable.
The example git identity is blanked out along with it.
This commit is contained in:
tiennm99 committed 2026-09-18 09:35:04 +07:00
1 parent f02de334e5
commit 2a4e635e09
6 files changed
+48 -7

No files matched your search

+4
View File
@@ -2,6 +2,10 @@
#
# cp .env.example .env
# 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
# Web UI login password. MUST NOT be blank -- the LinuxServer image serves
# code-server without authentication when PASSWORD is empty.
# Also used for SUDO_PASSWORD inside the container.
+14
View File
@@ -25,11 +25,25 @@ because this is a single-user dev box.
| Variable | Purpose |
| --- | --- |
| `SERVICE_HOSTNAME` | Container hostname, and the name the shell prompt shows. |
| `PASSWORD` | Web UI login, also the in-container sudo password. **A blank value disables authentication entirely.** |
| `GIT_NAME` / `GIT_EMAIL` | Git author and committer identity |
Generate a password with `openssl rand -base64 24`.
`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 the prompt reads `0`, the first
dot-separated field of `0.0.0.0`. code-server itself never reads `HOST` -- it
binds `[::]:8443` -- so overriding it only affects the prompt. bash is
unaffected; its `\h` uses the real hostname.
It is not called `HOSTNAME`, the obvious name, because Compose interpolation
lets the deploying shell's environment win over the `.env` file, and `HOSTNAME`
is set in every container -- including the one Coolify itself runs in. The
container would silently take Coolify's hostname instead of this value.
## Networking
Listens on `8443`. No ports are published — point the domain at that port in
+3 -1
View File
@@ -1,11 +1,13 @@
services:
code-server:
image: 'lscr.io/linuxserver/code-server:latest'
hostname: miti99-cs
hostname: ${SERVICE_HOSTNAME}
environment:
- PUID=1000
- PGID=1000
- TZ=Asia/Ho_Chi_Minh
# Hostname zsh's prompt reads, overriding the one Coolify injects.
- HOST=${SERVICE_HOSTNAME}
- DEFAULT_WORKSPACE=/config/workspace
- PWA_APPNAME=code-server
- 'DOCKER_MODS=linuxserver/mods:universal-package-install|linuxserver/mods:universal-docker|linuxserver/mods:code-server-golang|linuxserver/mods:code-server-nodejs|linuxserver/mods:code-server-npmglobal|linuxserver/mods:code-server-pnpm|linuxserver/mods:code-server-python3|linuxserver/mods:code-server-zsh'