Files
coder/examples/templates/docker-devcontainer/README.md
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.7 KiB
Markdown
Raw Normal View History

2023-07-12 10:22:39 -04:00
---
display_name: Docker-in-Docker Dev Containers
description: Provision Docker containers as Coder workspaces running Dev Containers via Docker-in-Docker.
icon: ../../../site/static/icon/docker.png
maintainer_github: coder
verified: true
tags: [docker, container, devcontainer]
2023-07-12 10:22:39 -04:00
---
# Remote Development on Dev Containers
2023-07-12 10:22:39 -04:00
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.
<!-- TODO: Add screenshot -->
2023-07-12 10:22:39 -04:00
## Prerequisites
### Infrastructure
The VM you run Coder on must have a running Docker socket and the `coder` user must be added to the Docker group:
```sh
# Add coder user to Docker group
sudo adduser coder docker
# Restart Coder server
sudo systemctl restart coder
# Test Docker
sudo -u coder docker ps
```
## Architecture
2023-07-12 10:22:39 -04:00
This example uses the `codercom/enterprise-node:ubuntu` Docker image as a base image for the workspace. It includes necessary tools like Docker and Node.js, which are required for running Dev Containers via the `@devcontainers/cli` tool.
2023-07-12 10:22:39 -04:00
This template provisions the following resources:
2023-07-12 10:22:39 -04:00
- Docker image (built by Docker socket and kept locally)
- Docker container (ephemeral)
- Docker volume (persistent on `/home/coder`)
- Docker volume (persistent on `/var/lib/docker`)
2023-07-12 10:22:39 -04:00
This means, when the workspace restarts, any tools or files outside of the home directory or docker library are not persisted.
For devcontainers running inside the workspace, data persistence is dependent on each projects `devcontainer.json` configuration.
2023-07-12 10:22:39 -04:00
> **Note**
> This template is designed to be a starting point! Edit the Terraform to extend the template to support your use case.