Rust development container for Visual Studio Code
cargo binstall ripgrep cargo-watchghcr.io/qdm12/rustdevcontainer:latest and ghcr.io/qdm12/rustdevcontainer:alpine
amd64 (1.64GB uncompressed image size)ghcr.io/qdm12/rustdevcontainer:debian
amd64 (1.62GB uncompressed image size) and arm64 (1.5GB uncompressed image size)user, 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 helmImage sizes are the uncompressed ones, as reported by podman image ls or docker image ls. The compressed size transferred on a pull is roughly a third of that.
See .devcontainer/README.md#Requirementsā
With style šÆ
docker run -it --rm -v "/yourrepopath:/repository" qmcgaw/devtainr:v0.2.0 -dev rust -path /repository -name projectname
If you run on Linux not as root, run the docker run command with --user="$(id -u):$(id -g)".
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*.Remote-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:
/usr/local/cargo (its CARGO_HOME) and /usr/local/rustup (its RUSTUP_HOME), 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 .devcontainer/README.md#Customizationā
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:ccb371adeā¦
Size
549.9 MB
Last updated
about 20 hours ago
docker pull qmcgaw/rustdevcontainer