You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provision Docker containers as [Coder workspaces](https://coder.com/docs/workspaces) with this example template.
13
13
14
-
<!-- TODO: Add screenshot -->
15
-
16
14
## Prerequisites
17
15
18
16
### Infrastructure
19
17
20
-
The VM you run Coder on must have a running Docker socket and the `coder` user must be added to the Docker group:
18
+
Coder must have access to a running Docker socket, and the `coder` user must be a member of the `docker` group:
21
19
22
-
```sh
20
+
```shell
23
21
# Add coder user to Docker group
24
-
sudo adduser coder docker
22
+
sudo usermod -aG docker coder
25
23
26
24
# Restart Coder server
27
25
sudo systemctl restart coder
@@ -36,15 +34,38 @@ Coder supports devcontainers with [envbuilder](https://github.com/coder/envbuild
36
34
37
35
This template provisions the following resources:
38
36
39
-
- Docker image (built by Docker socket and kept locally)
40
-
- Docker container pod (ephemeral)
41
-
- Docker volume (persistent on `/home/coder`)
37
+
- Docker image (persistent)
38
+
- Docker container (ephemeral)
39
+
- Docker volume (persistent on `/workspaces`)
42
40
43
-
This means, when the workspace restarts, any tools or files outside of the home directory are not persisted. To pre-bake tools into the workspace (e.g. `python3`), modify the container image. Alternatively, individual developers can [personalize](https://coder.com/docs/dotfiles) their workspaces with dotfiles.
41
+
with [`envbuilder`](https://github.com/coder/envbuilder).
42
+
The Git repository is cloned inside the `/workspaces` volume if not present.
43
+
Any local changes to the Devcontainer files inside the volume will be applied when you restart the workspace.
44
+
As you might suspect, any tools or files outside of `/workspaces` or not added as part of the Devcontainer specification are not persisted.
45
+
Edit the `devcontainer.json` instead!
44
46
45
47
> **Note**
46
48
> This template is designed to be a starting point! Edit the Terraform to extend the template to support your use case.
47
49
48
-
### Editing the image
50
+
## Docker-in-Docker
51
+
52
+
See the [Envbuilder documentation](https://github.com/coder/envbuilder/blob/main/docs/docker.md) for information on running Docker containers inside a devcontiner built by Envbuilder.
53
+
54
+
## Caching
55
+
56
+
To speed up your builds, you can run a local registry and use it as a cache. For example:
57
+
58
+
```shell
59
+
docker run --detach \
60
+
--volume registry-cache:/var/lib/registry \
61
+
--publish 5000:5000 \
62
+
--name registry-cache \
63
+
--net=host \
64
+
registry:2
65
+
```
66
+
67
+
Then, when creating a workspace, enter `localhost:5000/devcontainer-cache` for the parameter `cache_repo`.
49
68
50
-
Edit the `Dockerfile` and run `coder templates push` to update workspaces.
69
+
> [!NOTE] We recommend using a registry cache with authentication enabled.
70
+
> To allow Envbuilder to authenticate with the registry cache, specify the variable `cache_repo_docker_config_path`
71
+
> with the path to a Docker config `.json` on disk containing valid credentials for the registry.
0 commit comments