@@ -9,7 +9,8 @@ from inside Envbuilder.
9
9
> you may need to instead add the relevant content of the init script to your
10
10
> agent startup script in your template.
11
11
> For example:
12
- > ```
12
+ >
13
+ > ``` terraform
13
14
> resource "coder_agent" "dev" {
14
15
> ...
15
16
> startup_script = <<-EOT
@@ -43,7 +44,6 @@ docker run -it --rm \
43
44
ghcr.io/coder/envbuilder:latest
44
45
```
45
46
46
-
47
47
## Docker-in-Docker (DinD)
48
48
49
49
** Security:** Low
@@ -57,16 +57,16 @@ Example:
57
57
58
58
> Note that due to a lack of init system, the Docker daemon
59
59
> needs to be started separately inside the container. In this example, we
60
- > create a custom entrypoint to start the Docker daemon in the background and
61
- > call this entrypoint via ` ENVBUILDER_INIT_SCRIPT ` .
60
+ > create a custom script to start the Docker daemon in the background and
61
+ > call this entrypoint via the Devcontainer ` onCreateCommand ` lifecycle hook .
62
62
63
63
``` console
64
64
docker run -it --rm \
65
65
--privileged \
66
66
-v /tmp/envbuilder:/workspaces \
67
67
-e ENVBUILDER_GIT_URL=https://github.com/coder/envbuilder \
68
68
-e ENVBUILDER_DEVCONTAINER_DIR=/workspaces/envbuilder/examples/docker/02_dind \
69
- -e ENVBUILDER_INIT_SCRIPT=/entrypoint.sh \
69
+ -e ENVBUILDER_INIT_SCRIPT=bash \
70
70
ghcr.io/coder/envbuilder:latest
71
71
```
72
72
@@ -75,8 +75,14 @@ docker run -it --rm \
75
75
The above can also be accomplished using the [ ` docker-in-docker ` Devcontainer
76
76
feature] ( https://github.com/devcontainers/features/tree/main/src/docker-in-docker ) .
77
77
78
- > Note: we still need the custom entrypoint to start the docker startup script.
79
- > See https://github.com/devcontainers/features/blob/main/src/docker-in-docker/devcontainer-feature.json#L60
78
+ > Note: we still need the ` onCreateCommand ` to start Docker.
79
+ > See
80
+ > [ here] ( https://github.com/devcontainers/features/blob/main/src/docker-in-docker/devcontainer-feature.json#L65 )
81
+ > for more details.
82
+ >
83
+ > Known issue: ` /run ` does not get symlinked correctly to ` /var/run ` .
84
+ > To work around this, we create the symlink manually before running
85
+ > the script to start the Docker daemon.
80
86
81
87
Example:
82
88
@@ -86,7 +92,7 @@ docker run -it --rm \
86
92
-v /tmp/envbuilder:/workspaces \
87
93
-e ENVBUILDER_GIT_URL=https://github.com/coder/envbuilder \
88
94
-e ENVBUILDER_DEVCONTAINER_DIR=/workspaces/envbuilder/examples/docker/03_dind_feature \
89
- -e ENVBUILDER_INIT_SCRIPT=/entrypoint.sh \
95
+ -e ENVBUILDER_INIT_SCRIPT=bash \
90
96
ghcr.io/coder/envbuilder:latest
91
97
```
92
98
@@ -95,7 +101,7 @@ docker run -it --rm \
95
101
** Security:** Medium
96
102
** Convenience:** Medium
97
103
98
- This approach runs a Docker daemon in * rootless * mode.
104
+ This approach runs a Docker daemon in _ rootless _ mode.
99
105
While this still requires a privileged container, this allows you to restrict
100
106
usage of the ` root ` user inside the container, as the Docker daemon will be run
101
107
under a "fake" root user (via ` rootlesskit ` ). The user inside the workspace can
@@ -129,6 +135,7 @@ including transparently enabling Docker inside workspaces. Most notably, it
129
135
access inside their workspaces, if required.
130
136
131
137
Example:
138
+
132
139
``` console
133
140
docker run -it --rm \
134
141
-v /tmp/envbuilder:/workspaces \
0 commit comments