Implementation:Bentoml BentoML Docker Debian Setup
| Knowledge Sources | |
|---|---|
| Domains | DevContainer, Docker, Shell Scripting |
| Last Updated | 2026-02-13 15:00 GMT |
Overview
A Bash setup script that installs Docker CLI (Moby or Docker CE), Docker Compose (v1 and v2), and configures non-root Docker socket access inside a Debian-based VS Code devcontainer.
Description
This script is part of the Microsoft VS Code dev containers library. It enables Docker-from-Docker functionality inside the BentoML development container, allowing developers to build and manage Docker images from within the devcontainer. The script performs:
- Docker CLI installation: Installs either the Moby CLI (Microsoft's open-source Docker-compatible engine from Microsoft apt repos) or the official Docker CE CLI (from Docker's apt repos), depending on the
USE_MOBYflag. - Docker Compose installation: Installs Docker Compose v1 (standalone binary for x86_64, or via pip/pipx for other architectures) and Docker Compose v2 (as a Docker CLI plugin via the
moby-composeordocker-compose-pluginpackage). - Compose-switch installation: Installs the
compose-switchtool from Docker, which provides a compatibility shim between Docker Compose v1 and v2 CLIs, and configuresupdate-alternativesto select the desired version. - Non-root Docker access: Sets up a
dockergroup, adds the specified user to it, and generates a/usr/local/share/docker-init.shentrypoint script that usessocatto proxy the Docker socket with appropriate permissions for non-root users. - Version resolution: Includes a
find_version_from_git_tagsfunction that queries remote Git tags to resolve partial version specifiers to full version numbers. - SSL/GPG key management: Imports GPG keys for Microsoft or Docker apt repositories and configures signed apt sources.
Usage
This script is executed during devcontainer image build. It should be run as root. It provides Docker CLI capabilities inside the devcontainer for building BentoML container images during development.
Code Reference
Source Location
- Repository: Bentoml_BentoML
- File: .devcontainer/library-scripts/docker-debian.sh
- Lines: 1-355
Signature
# Invocation syntax:
./docker-debian.sh [enable_nonroot_docker] [source_socket] [target_socket] [username] [use_moby] [docker_version] [docker_compose_version]
Import
# Sourced/executed from a Dockerfile:
COPY library-scripts/*.sh /tmp/library-scripts/
RUN bash /tmp/library-scripts/docker-debian.sh "true" "/var/run/docker-host.sock" "/var/run/docker.sock" "vscode" "true" "latest" "v1"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| enable_nonroot_docker | string ("true"/"false") | No (default: "true") | Enable non-root user access to Docker socket via socat proxy |
| source_socket | string | No (default: "/var/run/docker-host.sock") | Path to the host Docker socket |
| target_socket | string | No (default: "/var/run/docker.sock") | Path for the container Docker socket |
| username | string | No (default: "automatic") | Non-root user to grant Docker access; "automatic" detects existing user |
| use_moby | string ("true"/"false") | No (default: "true") | Use Moby (open-source) instead of Docker CE |
| docker_version | string | No (default: "latest") | Docker CLI version to install |
| docker_compose_version | string | No (default: "v1") | Docker Compose version preference ("v1" or "v2") |
Outputs
| Name | Type | Description |
|---|---|---|
| Docker CLI | Binary | Installed Docker (Moby or CE) command-line client |
| Docker Compose | Binary | Docker Compose v1 and/or v2 binaries |
| compose-switch | Binary | Compatibility shim at /usr/local/bin/compose-switch
|
| docker-init.sh | Script | Entrypoint script at /usr/local/share/docker-init.sh for socket proxying
|
Usage Examples
# Default invocation with Moby engine
sudo bash /tmp/library-scripts/docker-debian.sh
# Use official Docker CE, specific version, Compose v2
sudo bash /tmp/library-scripts/docker-debian.sh "true" "/var/run/docker-host.sock" "/var/run/docker.sock" "vscode" "false" "20.10" "v2"
# Typical Dockerfile usage
RUN bash /tmp/library-scripts/docker-debian.sh "true" "/var/run/docker-host.sock" "/var/run/docker.sock" "${USERNAME}" "true"
ENTRYPOINT ["/usr/local/share/docker-init.sh"]
CMD ["sleep", "infinity"]