Coder.comC
Coder.comโ€ข4y agoโ€ข
11 replies
Skerit

Using a template without an explicit `user` breaks the workspace container

When starting the example docker-code-server as-is, I get this chdir - no such file or directory error:

2022-09-05 10:58:46.515 [WARN]    <./agent/agent.go:170>    (*agent).run.func1    agent script failed ...,
  "error": run:,
               github.com/coder/coder/agent.(*agent).runStartupScript,
                   /home/runner/work/coder/coder/agent/agent.go:375,
             - chdir /home/skerit: no such file or directory,
2022-09-05 10:58:46.516 [DEBUG]    (tailnet.wgengine)    <./tailnet/conn.go:521>    Logger.func1    [v1] using fake (no-op) tun device,
2022-09-05 10:58:46.518 [DEBUG]    (tailnet.wgengine)    <./tailnet/conn.go:521>    Logger.func1    [v1] magicsock: starting endpoint update (derp-map-update),
2022-09-05 10:58:46.516 [DEBUG]    (tailnet.wgengine)    <./tailnet/conn.go:521>    Logger.func1    [v1] using fake (no-op) OS network configurator,
2022-09-05 10:58:46.516 [DEBUG]    (tailnet.wgengine)    <./tailnet/conn.go:521>    Logger.func1    [v1] using fake (no-op) DNS configurator,
2022-09-05 10:58:46.516 [DEBUG]    (tailnet.wgengine)    <./tailnet/conn.go:521>    Logger.func1    dns: using dns.noopManager


I made an issue for it on Github https://github.com/coder/coder/issues/3870
There we found out the HOME environment somehow gets set to the username of user 1000 of the host server:
(It's set to /home/skerit when it should be /home/coder)

[skerit@test1 coder]$ env
HOSTNAME=test1
PWD=/home/coder
HOME=/home/skerit
ENTRYPOINTD=/entrypoint.d
LANG=en_US.UTF-8
CODER_AGENT_TOKEN=xxx
TERM=xterm
USER=coder
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=/usr/sbin/env


The workaround for this was to add this to the workspace resource:

resource "docker_container" "workspace" {
  ...
  user = "coder:coder"
}


This is on an Arch server, btw ๐Ÿ˜„
Was this page helpful?