Skip to content

Commit 75f4176

Browse files
authored
fix: persist the devtunnel file in a docker volume (coder#15731)
Addresses coder#15663. This PR saves the entire coder home directory in a Docker volume to make the dev tunnel URL persistent across container restarts. I initially wanted to persist only the config directory, but Docker Compose cannot set permissions on a named volume unless the directory it’s mounted on already exists within the container. The `/home/coder/.config` directory, however, is not created by default in the Dockerfile. When I attempt to mount it, [Docker creates it with root permissions](moby/moby#2259 (comment)), and Coder cannot write to it. I encounter the following error: ``` coder-1 | Started HTTP listener at http://0.0.0.0:7080 coder-1 | Opening tunnel so workspaces can connect to your deployment. For production scenarios, specify an external access URL coder-1 | Encountered an error running "coder server", see "coder server --help" for more information coder-1 | error: create tunnel: read or generate config: get config path: mkdirall config dir "/home/coder/.config/coderv2": mkdir /home/coder/.config/coderv2: permission denied ``` Creating the directory in the Dockerfile would resolve the issue for new images but would break `docker-compose.yml` for all existing Coder images. Mounting the entire home directory avoids this problem, but it makes it less clear to admins which files need to be persisted. It’s a trade-off - I believe keeping Docker Compose backwards-compatible is more important, and I hope the added comment clarifies the purpose of the volume for new users.
1 parent 14a6030 commit 75f4176

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

docker-compose.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ services:
2121
# - "998" # docker group on host
2222
volumes:
2323
- /var/run/docker.sock:/var/run/docker.sock
24+
# Run "docker volume rm coder_coder_home" to reset the dev tunnel url (https://abc.xyz.try.coder.app).
25+
# This volume is not required in a production environment - you may safely remove it.
26+
# Coder can recreate all the files it needs on restart.
27+
- coder_home:/home/coder
2428
depends_on:
2529
database:
2630
condition: service_healthy
@@ -47,3 +51,4 @@ services:
4751
retries: 5
4852
volumes:
4953
coder_data:
54+
coder_home:

0 commit comments

Comments
 (0)