Skip to content

Commit 9538680

Browse files
committed
Use canonical /run/docker.sock path for mount unit
systemd rejects mount unit Where= paths containing symlinks. On Debian, /var/run is a symlink to /run, so Where=/var/run/docker.sock fails with a resources error and coder-agent.service never starts (Requires= fails). Rename the mount unit to run-docker.sock.mount and bind to /run/docker.sock. Clients hitting /var/run/docker.sock still resolve via the symlink.
1 parent 9390296 commit 9538680

6 files changed

Lines changed: 11 additions & 10 deletions

File tree

main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,8 @@ resource "docker_container" "workspace" {
563563
# Stash the host socket outside /run, which systemd remounts as a fresh
564564
# tmpfs at boot and would shadow a bind mount placed there. A systemd
565565
# .mount unit in the image re-binds /host-docker.sock onto
566-
# /var/run/docker.sock after /run is set up.
566+
# /run/docker.sock after /run is set up. (/var/run is a symlink to /run on
567+
# Debian; systemd rejects non-canonical mount unit paths.)
567568
volumes {
568569
container_path = "/host-docker.sock"
569570
host_path = "/var/run/docker.sock"

src/base/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ RUN printf '\nif [ -d /etc/profile.d ]; then\n for i in /etc/profile.d/*.sh; do
128128
RUN mkdir -p /etc/coder
129129
COPY src/base/coder-agent.service /etc/systemd/system/coder-agent.service
130130
COPY src/base/web-shell.service /etc/systemd/system/web-shell.service
131-
COPY src/base/var-run-docker.sock.mount /etc/systemd/system/var-run-docker.sock.mount
131+
COPY src/base/run-docker.sock.mount /etc/systemd/system/run-docker.sock.mount
132132
COPY src/base/docker-sock.tmpfiles.conf /etc/tmpfiles.d/docker-sock.conf
133133
COPY --chmod=0755 src/base/web-shell-launch.sh /usr/local/bin/web-shell-launch
134134
RUN install -m 0644 /dev/null /var/log/web-shell.log && \
135135
chown coder:coder /var/log/web-shell.log && \
136-
systemctl enable coder-agent.service web-shell.service var-run-docker.sock.mount
136+
systemctl enable coder-agent.service web-shell.service run-docker.sock.mount
137137

138138
# Entrypoint claims fresh-volume mountpoints for the workspace user before
139139
# systemd starts. See entrypoint.sh for rationale.

src/base/coder-agent.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[Unit]
22
Description=Coder Agent
3-
After=network-online.target var-run-docker.sock.mount
3+
After=network-online.target run-docker.sock.mount
44
Wants=network-online.target
5-
Requires=var-run-docker.sock.mount
5+
Requires=run-docker.sock.mount
66
ConditionPathExists=/etc/coder/agent-init.sh
77

88
[Service]

src/base/docker-sock.tmpfiles.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f /var/run/docker.sock 0660 root docker -
1+
f /run/docker.sock 0660 root docker -
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Unit]
2-
Description=Bind-mount host Docker socket into /var/run
2+
Description=Bind-mount host Docker socket into /run
33
DefaultDependencies=no
44
After=systemd-tmpfiles-setup.service
55
Requires=systemd-tmpfiles-setup.service
@@ -9,7 +9,7 @@ Conflicts=shutdown.target
99

1010
[Mount]
1111
What=/host-docker.sock
12-
Where=/var/run/docker.sock
12+
Where=/run/docker.sock
1313
Type=none
1414
Options=bind
1515

src/base/web-shell.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[Unit]
22
Description=web-shell
3-
After=network-online.target var-run-docker.sock.mount
3+
After=network-online.target run-docker.sock.mount
44
Wants=network-online.target
5-
Requires=var-run-docker.sock.mount
5+
Requires=run-docker.sock.mount
66

77
[Service]
88
Type=simple

0 commit comments

Comments
 (0)