@@ -9,7 +9,8 @@ from inside Envbuilder.
99> you may need to instead add the relevant content of the init script to your
1010> agent startup script in your template.
1111> For example:
12- > ```
12+ >
13+ > ``` terraform
1314> resource "coder_agent" "dev" {
1415> ...
1516> startup_script = <<-EOT
@@ -43,7 +44,6 @@ docker run -it --rm \
4344 ghcr.io/coder/envbuilder:latest
4445```
4546
46-
4747## Docker-in-Docker (DinD)
4848
4949** Security:** Low
@@ -57,16 +57,16 @@ Example:
5757
5858> Note that due to a lack of init system, the Docker daemon
5959> 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 .
6262
6363``` console
6464docker run -it --rm \
6565 --privileged \
6666 -v /tmp/envbuilder:/workspaces \
6767 -e ENVBUILDER_GIT_URL=https://github.com/coder/envbuilder \
6868 -e ENVBUILDER_DEVCONTAINER_DIR=/workspaces/envbuilder/examples/docker/02_dind \
69- -e ENVBUILDER_INIT_SCRIPT=/entrypoint.sh \
69+ -e ENVBUILDER_INIT_SCRIPT=bash \
7070 ghcr.io/coder/envbuilder:latest
7171```
7272
@@ -75,8 +75,14 @@ docker run -it --rm \
7575The above can also be accomplished using the [ ` docker-in-docker ` Devcontainer
7676feature] ( https://github.com/devcontainers/features/tree/main/src/docker-in-docker ) .
7777
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.
8086
8187Example:
8288
@@ -86,7 +92,7 @@ docker run -it --rm \
8692 -v /tmp/envbuilder:/workspaces \
8793 -e ENVBUILDER_GIT_URL=https://github.com/coder/envbuilder \
8894 -e ENVBUILDER_DEVCONTAINER_DIR=/workspaces/envbuilder/examples/docker/03_dind_feature \
89- -e ENVBUILDER_INIT_SCRIPT=/entrypoint.sh \
95+ -e ENVBUILDER_INIT_SCRIPT=bash \
9096 ghcr.io/coder/envbuilder:latest
9197```
9298
@@ -95,7 +101,7 @@ docker run -it --rm \
95101** Security:** Medium
96102** Convenience:** Medium
97103
98- This approach runs a Docker daemon in * rootless * mode.
104+ This approach runs a Docker daemon in _ rootless _ mode.
99105While this still requires a privileged container, this allows you to restrict
100106usage of the ` root ` user inside the container, as the Docker daemon will be run
101107under 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
129135access inside their workspaces, if required.
130136
131137Example:
138+
132139``` console
133140docker run -it --rm \
134141 -v /tmp/envbuilder:/workspaces \
0 commit comments