basedevcontainer
basedevcontainer copied to clipboard
Base development Docker image used by other development Docker images
Base Dev Container
Base Alpine development container for Visual Studio Code, used as base image by other images
Features
-
qmcgaw/basedevcontainer:alpine
(or:latest
) based on Alpine 3.16 in 209MB -
qmcgaw/basedevcontainer:debian
based on Debian Buster Slim in 376MB - All images are compatible with
amd64
,386
,arm64
,armv7
,armv6
andppc64le
CPU architectures - Contains the packages:
-
libstdc++
: needed by the VS code server -
zsh
: main shell instead of/bin/sh
-
git
: interact with Git repositories -
openssh-client
: use SSH keys -
nano
: edit files from the terminal
-
- Contains the binaries:
-
gh
: interact with Github with the terminal -
docker
-
docker-compose
anddocker compose
docker plugin -
docker buildx
docker plugin -
bit
-
devtainr
-
- Custom integrated terminal
- Based on zsh and oh-my-zsh
- Uses the Powerlevel10k theme
- With Logo LS as a replacement for
ls
- Shows information on login; easily extensible
- Cross platform
- Easily bind mount your SSH keys to use with git
- Manage your host Docker from within the dev container on Linux, MacOS and Windows
- Docker uses buildkit by default, with the latest Docker client binary.
- Extensible with docker-compose.yml
- Supports SSH keys with Windows (Hyperv) bind mounts at /tmp/.ssh
Requirements
-
Docker installed and running
- If you don't use Linux, share the directories
~/.ssh
and the directory of your project with Docker Desktop
- If you don't use Linux, share the directories
- Docker Compose installed
- VS code installed
- VS code remote containers extension installed
Setup for a project
-
Download 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 .devcontainer cd .devcontainer wget -q https://raw.githubusercontent.com/qdm12/basedevcontainer/master/.devcontainer/devcontainer.json wget -q https://raw.githubusercontent.com/qdm12/basedevcontainer/master/.devcontainer/docker-compose.yml
-
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
Remote-Containers: Open Folder in Container...
and choose your project directory
More
devcontainer.json
- You can change the
"postCreateCommand"
to be relevant to your situation. In example it could beecho "downloading" && npm i
to combine two commands - You can change the extensions installed in the Docker image within the
"extensions"
array - VScode settings can be changed or added in the
"settings"
object.
docker-compose.yml
- You can publish a port to access it from your host
- Add containers to be launched with your development container. In example, let's add a postgres database.
-
Add this block to
.devcontainer/docker-compose.yml
database: image: postgres restart: always environment: POSTGRES_PASSWORD: password
-
In
.devcontainer/devcontainer.json
change the line"runServices": ["vscode"],
to"runServices": ["vscode", "database"],
-
In the VS code command palette, rebuild the container
-
Development image
You can build and extend the Docker development image to suit your needs.
-
You can build the development image yourself:
docker build -t qmcgaw/basedevcontainer -f alpine.Dockerfile https://github.com/qdm12/basedevcontainer.git
-
You can extend the Docker image
qmcgaw/basedevcontainer
with your own instructions.-
Create a file
.devcontainer/Dockerfile
withFROM qmcgaw/basedevcontainer
-
Append instructions to the Dockerfile created. For example:
-
Add more Go packages and add an alias
FROM qmcgaw/basedevcontainer COPY . . RUN echo "alias ls='ls -al'" >> ~/.zshrc
-
Add some Alpine packages, you will need to switch to
root
:FROM qmcgaw/basedevcontainer USER root RUN apk add bind-tools USER vscode
-
-
Modify
.devcontainer/docker-compose.yml
and addbuild: .
in the vscode service. -
Open the VS code command palette and choose
Remote-Containers: Rebuild container
-
-
You can bind mount a file at
/home/vscode/.welcome.sh
to modify the welcome message (use/root/.welcome.sh
forroot
)
TODO
- [ ]
bit complete
yes flag - [ ] Firewall, see this
- [ ] Extend another docker-compose.yml
- [ ] Fonts for host OS for the VS code shell
- [ ] Gifs and images
- [ ] Install VS code server and extensions in image, waiting for this issue