Golang development container for Visual Studio Code Remote Containers Development
50K+
Ultimate Go development container for Visual Studio Code
amd64, 386, arm64, armv6 and armv7 CPUsghcr.io/qdm12/godevcontainer:alpine and ghcr.io/qdm12/godevcontainer
ghcr.io/qdm12/godevcontainer:debian
amd64 and arm64user, uid/gid 1000 by default, configurable), see Non-root user
apk (Alpine) and apt-get (Debian) install packages from that user, no sudo involvedkubectl, kubectx, kubens, stern and helm~/.ssh directory and the directory of your project with Docker DesktopWith style 💯
docker run -it --rm -v "/yourrepopath:/repository" qmcgaw/devtainr:v0.2.0 -dev go -path /repository -name projectname
Or use the built binary
Or manually: download this repository and put the .devcontainer directory in your project. It holds a docker/ and a podman/ configuration, pick the one matching your container engine.
.devcontainer/*/devcontainer.json in the "settings" section as .vscode/settings.json take precedence over the settings defined in .devcontainer//devcontainer.json*.Dev Containers: Open Folder in Container... and choose your project directoryThe image runs using an unprivileged account user, created by the base image.
💁 In case you need root access, see the root user section
The non root user is configurable with container build arguments, defined both in the Dockerfiles and in the 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 |
The unprivileged account:
/go (its GOPATH), and the state directories of the package manager, so it can install and remove packages without 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 its configuration files are symlinks into /home/user.
Note however that by default the zsh history and 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.
See the .devcontainer/README.md document in your repository.
When you extend the image in a Dockerfile, the build runs as the unprivileged account: use USER root before instructions that do need root, and USER user to give it back.
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
This repository is under an MIT license unless indicated otherwise.
Content type
Image
Digest
sha256:052550378…
Size
396.7 MB
Last updated
about 20 hours ago
docker pull qmcgaw/godevcontainer