One of the joys of working with devcontainers is that a new user, on a new machine, can be up-and-running with a fully configured development environment in minutes. However, one of the challenges with working with devcontainers built from Dockerfiles is that they can be cumbersome, time-consuming, and error-prone to build. This is especially true when you are working with multiple devcontainers, or you are working on a project that uses a devcontainer that you don't own. Mechanisms like devcontainer features can help to reduce the complexity of developing devcontainers, but they can become burdensome as they need to be baked into the final image - often at a cost of poor layer caching.
Using a pre-built devcontainer image can help to solve these problems.
This repository contains prebuilt devcontainer images for some of the languages and frameworks I am most frequently building prototypes in. This not only helps me to build proofs-of-concept faster, but also helps me reliably share those proofs-of-concept with other developers.
- Docker Desktop (v4.21.1 or higher) or equivalent
- Visual Studio Code (v.1.80 or higher)
- Dev containers extension (v0.299 or higher)
- Clone this repository
- Open the repository in Visual Studio Code
- When you see the prompt "Folder contains a Dev Container configuration file", click "Reopen in Container", or select "Dev Containers: Reopen in Container" from the Command Palette (Ctrl+Shift+P)
The following images are available:
- .NET:
ghcr.io/iaingalloway/devcontainers/dotnet:1.2-dotnet8.0.300
- Go:
ghcr.io/iaingalloway/devcontainers/go:1.2-go1.22.0
- Hugo:
ghcr.io/iaingalloway/devcontainers/hugo:1.2-hugo0.126.2
- Javascript (Node):
ghcr.io/iaingalloway/devcontainers/javascript:1.2-node22.2.0
- Python:
ghcr.io/iaingalloway/devcontainers/python:1.1-python3.12.3
- Create a
.devcontainer
folder in the root of your project - Create a
devcontainer.json
file in the.devcontainer
folder with the following content, replacing the image name with the image you want to use:
{
"name": "My Awesome Project Devcontainer",
"image": "ghcr.io/iaingalloway/devcontainers/dotnet::1.2-dotnet8.0.300",
"runArgs": [
"--name",
"my-awesome-project-devcontainer",
"--network=host"
]
}
When you open the project in Visual Studio Code, you will be prompted to reopen the project in a devcontainer.
The devcontainers in this repo have the following features:
- Docker CLI using the Docker outside of Docker pattern, allowing the devcontainer to interact with the host's docker daemon
- Kubectl
- Helm
- Starship prompt
- Chezmoi to import and manage dotfiles
Additionally, the devcontainers mount ~/.kube/
, ~/.ssh/
, and ~/.gitconfig
. If '~/.gitconfig' contains a key for the user's github username, this is used to configure Chezmoi.
To build the images locally, run the following commands:
devcontainer build --workspace-folder ./src/base --image-name ghcr.io/iaingalloway/devcontainers/base:local
devcontainer build --workspace-folder ./src/dotnet --image-name ghcr.io/iaingalloway/devcontainers/dotnet:local
devcontainer build --workspace-folder ./src/go --image-name ghcr.io/iaingalloway/devcontainers/go:local
devcontainer build --workspace-folder ./src/hugo --image-name ghcr.io/iaingalloway/devcontainers/hugo:local
devcontainer build --workspace-folder ./src/javascript --image-name ghcr.io/iaingalloway/devcontainers/javascript:local
devcontainer build --workspace-folder ./src/python --image-name ghcr.io/iaingalloway/devcontainers/python:local