Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Bentoml BentoML Docker Debian Setup

From Leeroopedia
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:

  1. 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_MOBY flag.
  2. 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-compose or docker-compose-plugin package).
  3. Compose-switch installation: Installs the compose-switch tool from Docker, which provides a compatibility shim between Docker Compose v1 and v2 CLIs, and configures update-alternatives to select the desired version.
  4. Non-root Docker access: Sets up a docker group, adds the specified user to it, and generates a /usr/local/share/docker-init.sh entrypoint script that uses socat to proxy the Docker socket with appropriate permissions for non-root users.
  5. Version resolution: Includes a find_version_from_git_tags function that queries remote Git tags to resolve partial version specifiers to full version numbers.
  6. 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

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"]

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment