Base development container for Visual Studio Code, used as base image by other images
50K+
Base Alpine development container for Visual Studio Code, used as base image by other images
ghcr.io/qdm12/basedevcontainer:alpine (or :latest) based on Alpine 3.24 in 250MBghcr.io/qdm12/basedevcontainer:debian based on Debian Trixie Slim in 438MBamd64, 386, arm64, armv7, armv6 and ppc64le CPU architectureslibstdc++: needed by the VS code serverzsh: main shell instead of /bin/shgit: interact with Git repositoriesopenssh-client: use SSH keysnano: edit files from the terminalgh: interact with Github with the terminaldocker, podman-remote (aliased as podman)docker-compose and docker compose docker plugindocker buildx docker pluginbitdevtainrls
user, uid/gid 1000 by default, configurable), see Non-root user
apk (Alpine) and apt-get (Debian) install packages from that user, no sudo involved~/.ssh and the directory of your project with Docker DesktopDownload this repository and put the .devcontainer directory in your project.
Alternatively, use this shell script from your project path
# we assume you are in /yourpath/myproject
mkdir -p .devcontainer/docker .devcontainer/podman
wget -qO .devcontainer/README.md https://raw.githubusercontent.com/qdm12/basedevcontainer/master/.devcontainer/README.md
wget -qO .devcontainer/.dockerignore https://raw.githubusercontent.com/qdm12/basedevcontainer/master/.devcontainer/.dockerignore
wget -qO .devcontainer/Dockerfile https://raw.githubusercontent.com/qdm12/basedevcontainer/master/.devcontainer/Dockerfile
wget -qO .devcontainer/docker/devcontainer.json https://raw.githubusercontent.com/qdm12/basedevcontainer/master/.devcontainer/docker/devcontainer.json
wget -qO .devcontainer/podman/devcontainer.json https://raw.githubusercontent.com/qdm12/basedevcontainer/master/.devcontainer/podman/devcontainer.json
If you have a .vscode/settings.json, eventually move the settings to .devcontainer/*/devcontainer.json in the "settings" section as .vscode/settings.json take precedence over the settings defined in .devcontainer/devcontainer.json.
Open the command palette in Visual Studio Code (CTRL+SHIFT+P) and select Dev Containers: Open Folder in Container... and choose your project directory
The image runs using an unprivileged account user.
💁 In case you need root access, see the root user section
The non root user is configurable with container build arguments, defined both in Dockerfiles and in devcontainer.json files:
| Build argument | Default | Description |
|---|---|---|
USERNAME | user | account name, home is /home/$USERNAME. Update the "remoteUser" key and mount targets in devcontainer.json to match this one if changed. |
GROUP_NAME | user | name of the account's primary group |
USER_UID | 1000 | user ID of the account |
USER_GID | 1000 | group ID of the account's primary group ($GROUP_NAME) |
DOCKER_GID | create a docker group with this GID and put the account in it, to reach a rootful engine's socket, see Container engine socket |
The unprivileged account:
sudo or doas/usr/local/bin, /etc/ssl/certs, /var/log...), which all belong to $GROUP_NAME and are group-writable./root and /etc/shadowOn system package management, note:
dbus); the fix is to finish the job as root for example docker exec --user root <container-name> sh -c 'apt-get install -y dbus && dpkg --configure -a'If you need to run a command as root, exec in the container using for example
docker exec --user root <container-name> command
Root has the same terminal setup as the unprivileged account, given all the configuration files are symlinked into /home/user.
Note however that by default the zsh historyand ssh files are not symlinked or copied from the unprivileged user to root.
The shell prints Running as root at startup, so you always know which account a terminal belongs to.
"postCreateCommand" to be relevant to your situation. In example it could be echo "downloading" && npm i to combine two commands"extensions" array"settings" object.You can create a .devcontainer/docker-compose.yml to create the devcontainer and other containers at the same time:
services:
vscode: # configured in devcontainer.json
build: .
postgres: # example of a database container
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: password
And change the following in your relevant devcontainer.json:
"build": { "dockerfile": "../Dockerfile" },"dockerComposeFile": "../docker-compose.yml","overrideCommand": true,"service": "vscode","runServices": ["vscode", "postgres"],Finally, open the command palette in Visual Studio Code (CTRL+SHIFT+P) and select Dev-Containers: Rebuild Container
You can build and extend the Docker development image to suit your needs.
You can build the development image yourself:
docker build -t ghcr.io/qdm12/basedevcontainer -f alpine.Dockerfile https://github.com/qdm12/basedevcontainer.git
You can extend the Docker image ghcr.io/qdm12/basedevcontainer with your own instructions.
Modify the .devcontainer/Dockerfile by appending instructions. For example to add Alpine packages:
FROM ghcr.io/qdm12/basedevcontainer
RUN apk add bind-tools
Use USER root before instructions that do need root, and USER user to give it back.
Open the command palette in Visual Studio Code (CTRL+SHIFT+P)
Select Dev-Containers: Rebuild Container
You can bind mount a file at /home/user/.welcome.sh to modify the welcome message.
You can change the oh-my-zsh plugins loaded at shell startup by dropping a ~/.zshrc-plugins file. It is sourced before oh-my-zsh reads the plugins variable, so it can replace or extend the default list. For example, to add Go plugins in a child image:
FROM ghcr.io/qdm12/basedevcontainer
RUN echo 'plugins=($plugins golang)' > /home/user/.zshrc-plugins
Setting plugins in ~/.zshrc-specific has no effect: that file is sourced after oh-my-zsh has loaded the plugins, so it is for aliases and environment variables.
You can either use an SSH agent (preferred, more secure) or bind mount your ~/.ssh directory at /mnt/ssh, or not use SSH at all. See the .devcontainer/README.md#SSH-keys for more information.
bit complete yes flagContent type
Image
Digest
sha256:5c5a2dc9a…
Size
122.1 MB
Last updated
1 day ago
docker pull qmcgaw/basedevcontainer