--- title: "devcontainer" author: "James" date: "2022-12-28" categories: [containers] description: Notes on devcontainer work. --- A few weeks I took a look a vscode's devcontainer standard. It is a standard way of building and running a docker container for development from a specially formatted json file. Over the holiday I played around a little bit with it. They have a node cli program that can build, launch, and attach to the container from the json file without vscode hosted [here](https://github.com/devcontainers/cli). For the most part the special json file defines all the stuff you would think it does and works as I would have expected. The coolest thing I saw with it is they have this concept of "features". A lot of time with Dockerfiles there is a lot of repetition with the same code repeated in multiple Dockerfiles for different images. There's different ways to solve this I've seen. My custom development container handler (`dev_container`) uses [templates](https://github.com/jpace121/dev_contain_templates/blob/master/templates/base.Dockerfile.template), for example. Te vscode solution has this thing called a "feature". They build a base image from a Dockerfile like normal, and then add listed "features" on top of the original Dockerfile. Each feature is basically a tar file with a well known named script that the build thing runs that can modify the original image. I was able to write my own "feature" [here](https://github.com/jpace121/jpace121-devcontainer-features/blob/main/src/jpace121-devel/install.sh) which adds my normal cli stuff (like `ag` and `emacs`) to an image pretty easily. They provide a github action to publish the features as an OCI archive, so I got that for free basically.