Sign inSign up

papereira/devcontainer-base

By papereira

•Updated over 2 years ago

Alpine Linux docker image used to build development containers for Visual Studio Code

Image
Developer tools
0

482

papereira/devcontainer-base repository overview

⁠devcontainer-base

This repository holds an Alpine Linux docker image used to build development containers for Visual Studio Code

⁠Features

This image is quite similar to the one created by Quentin McGaw⁠. The main differences are:

  • Uses vim as the editor instead of nano
  • Uses avit oh-my-zsh theme instead of Powerlevel10k theme
  • Adds git-extras to the plugins initialized by oh-my-zsh
  • Uses starship⁠ prompt

⁠Building the base image

The Dockerfile makes extensive use of build arguments⁠ most of them with default values set in the Dockerfile. The only build argument that doesn't have default values is VERSION.

To build the image clone this repository and then issue the following command:

docker build \
  --build-arg VERSION=`date -u +"%Y%m%d"`-`git rev-parse --short HEAD` \
  -t <IMAGE _NAME>:<IMAGE_TAG> .

Note: Replace IMAGE_NAME and IMAGE_TAG with values that make sense for your use case. In the example above the VERSION is set by concatenating current date with the git revision. Feel free to use any other value that makes sense for you.

⁠Customizing build via build arguments

This is a list of the build arguments used and their default values:

Build Argumentdefault value
ALPINE_VERSION3.20
USERNAMEvscode
USER_UID1000
USER_GID1000
VERSION

Note: It is not recommended to change most of these default values as a multi stage build is used and you may run into issues such as unexistent docker images depending on the version numbers you set.

The default user for the generated image is vscode. Let's say you want the generated image to have a different user. Use the same command as listed above to build the docker image but pass an additional build argument, USERNAME:

docker build \
  --build-arg VERSION=`date -u +"%Y%m%d"`-`git rev-parse --short HEAD` \
  --build-arg USERNAME=demo \
  --platform <PLATFORM> \
  -t <IMAGE NAME>:<IMAGE TAG> .

The generated image will run under the demo user instead of the default vscode one.

⁠Running a container using the generated image

To run a container using the generated docker image the following command can be used:

docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -e TZ=<TIMEZONE> <IMAGE_ID>

-e TZ="Europe/Madrid" will set the timezone to Madrid

This command will run in interactive mode and remove the container we exit it. We are also mounting a volume that allows us to connect the container to the host docker socket.

⁠Credits

All the heavy lifting was made by Quentin McGaw⁠ the base container available here only has minor tweaks to the base image created by Quentin⁠.

⁠License

This repository is under an MIT license⁠ unless indicated otherwise.

Tag summary

Content type

Image

Digest

sha256:8667cd8de…

Size

89.8 MB

Last updated

over 2 years ago

docker pull papereira/devcontainer-base