|
| 1 | +--- |
| 2 | +display_name: Docker-in-Docker Dev Containers |
| 3 | +description: Provision Docker containers as Coder workspaces running Dev Containers via Docker-in-Docker. |
| 4 | +icon: ../../../site/static/icon/docker.png |
| 5 | +maintainer_github: coder |
| 6 | +verified: true |
| 7 | +tags: [docker, container, devcontainer] |
| 8 | +--- |
| 9 | + |
| 10 | +# Remote Development on Dev Containers |
| 11 | + |
| 12 | +Provision Docker containers as [Coder workspaces](https://coder.com/docs/workspaces) running [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers) via Docker-in-Docker. |
| 13 | + |
| 14 | +<!-- TODO: Add screenshot --> |
| 15 | + |
| 16 | +## Prerequisites |
| 17 | + |
| 18 | +### Infrastructure |
| 19 | + |
| 20 | +The VM you run Coder on must have a running Docker socket and the `coder` user must be added to the Docker group: |
| 21 | + |
| 22 | +```sh |
| 23 | +# Add coder user to Docker group |
| 24 | +sudo adduser coder docker |
| 25 | + |
| 26 | +# Restart Coder server |
| 27 | +sudo systemctl restart coder |
| 28 | + |
| 29 | +# Test Docker |
| 30 | +sudo -u coder docker ps |
| 31 | +``` |
| 32 | + |
| 33 | +## Architecture |
| 34 | + |
| 35 | +This example uses the `codercom/enterprise-node:ubuntu` Docker image as a base image for the workspace. It was chosen because it includes necessary tools like Docker and Node.js, which are required for running Dev Containers via the `@devcontainers/cli` tool. |
| 36 | + |
| 37 | +This template provisions the following resources: |
| 38 | + |
| 39 | +- Docker image (built by Docker socket and kept locally) |
| 40 | +- Docker container pod (ephemeral) |
| 41 | +- Docker volume (persistent on `/home/coder`) |
| 42 | +- Docker volume (persistent on `/var/lib/docker`) |
| 43 | + |
| 44 | +This means, when the workspace restarts, any tools or files outside of the home directory or docker library are not persisted. |
| 45 | + |
| 46 | +For devcontainers running inside the workspace, data persistence is dependent on each projects `devcontainer.json` configuration. |
| 47 | + |
| 48 | +> **Note** |
| 49 | +> This template is designed to be a starting point! Edit the Terraform to extend the template to support your use case. |
0 commit comments