How to Build Specific Docker Images with Custom Language Profiles Using LabNow AI

To build specific Docker images with custom language profiles in LabNow AI, pass the ARG_PROFILE_<LANG> build arguments when building the core image, using comma-separated values like base,datascience,torch to include only the language runtimes and libraries you need.

LabNow AI provides a modular containerization framework that allows you to build specific Docker images with custom language profiles tailored to your exact development requirements. The architecture separates the minimal operating system layer from the language-specific tooling, enabling you to compose lightweight images that contain only the runtimes and libraries you actually need, from Python data science stacks to multi-language polyglot environments.

Understanding the LabNow Docker Image Architecture

The LabNow foundation repository uses a layered approach to Docker image construction, allowing you to build specific Docker images with custom language profiles by combining a minimal base with selective language tooling.

Base Image Layer

The docker_base/Dockerfile defines the minimal operating system layer. This file creates lightweight Ubuntu-based images that may include CUDA drivers for GPU support or database clients, but excludes all language-specific toolchains. Other images inherit from this layer using the BASE_NAMESPACE and BASE_IMG build arguments.

Core Image Layer

The docker_core/Dockerfile extends the base layer and implements the profile selection logic. This Dockerfile accepts build arguments in the pattern ARG_PROFILE_<LANG> and executes the corresponding setup functions. According to the source code in lines 31-94, the Dockerfile loops through comma-separated profile values:

ARG ARG_PROFILE_PYTHON
...
RUN set -eux \
    && for profile in $(echo $ARG_PROFILE_PYTHON | tr "," "\n") ; do \
         (setup_python_${profile}) ; \
       done ...

Setup Scripts and Package Lists

The docker_atom/work/script-setup.sh file implements the individual setup_<lang>_<profile>() functions called during the build process. For example, setup_python_datascience installs Python data science libraries, while setup_R_base configures the R runtime.

Package specifications reside in docker_core/work/ using file extensions that indicate the package manager:

  • .apt files for system packages
  • .pip files for Python packages
  • .conda files for Conda environments

Selecting Language Profiles with Build Arguments

When you build specific Docker images with custom language profiles, you control the contents through build-time arguments that follow the pattern ARG_PROFILE_<LANG>. Each argument accepts a comma-separated list of profile identifiers.

Common build-time arguments:

Argument Typical Values Installs
ARG_PROFILE_PYTHON base, datascience, nlp, cv, torch, tf2 Python runtime with specific package sets
ARG_PROFILE_R base, datascience, rstudio R runtime and CRAN packages
ARG_PROFILE_NODEJS base, pnpm, bun Node.js and alternative package managers
ARG_PROFILE_JAVA base, maven JDK and build tools
ARG_PROFILE_GO base Go toolchain
ARG_PROFILE_RUST base Rust toolchain
ARG_PROFILE_JULIA base Julia binaries
ARG_PROFILE_LATEX base, cjk LaTeX distribution with CJK support

If you omit a profile argument entirely, that language runtime is excluded from the final image, minimizing image size.

Building Custom Docker Images: Practical Examples

The following examples demonstrate how to build specific Docker images with custom language profiles for various use cases. All examples assume you are executing commands from the repository root.

Minimal Python-Only Image

To create a lightweight image containing only the base Python runtime without additional data science libraries:

docker build \
  --build-arg BASE_NAMESPACE=labnow \
  --build-arg BASE_IMG=base \
  --build-arg ARG_PROFILE_PYTHON=base \
  -t mylab/python-base \
  -f docker_core/Dockerfile .

This produces an image with Python installed but excludes heavy libraries like NumPy or Pandas, resulting in a significantly smaller footprint.

Full-Stack Data Science Environment

To build specific Docker images with custom language profiles combining Python data science, R statistics, and LaTeX document processing with CJK font support:

docker build \
  --build-arg BASE_NAMESPACE=labnow \
  --build-arg BASE_IMG=base \
  --build-arg ARG_PROFILE_PYTHON=base,datascience,torch,tf2 \
  --build-arg ARG_PROFILE_R=base,datascience \
  --build-arg ARG_PROFILE_LATEX=cjk \
  -t mylab/datasci-full \
  -f docker_core/Dockerfile .

This configuration installs Python with PyTorch and TensorFlow 2, R with statistical modeling packages, and LaTeX with Chinese, Japanese, and Korean font support.

GPU-Enabled PyTorch Image

To build specific Docker images with custom language profiles for GPU-accelerated machine learning, inherit from the CUDA base image and specify the torch profile:

docker build \
  --build-arg BASE_NAMESPACE=labnow \
  --build-arg BASE_IMG=nvidia-cuda \
  --build-arg ARG_PROFILE_PYTHON=torch \
  -t mylab/pytorch-gpu \
  -f docker_core/Dockerfile .

The setup_python_torch function in docker_atom/work/script-setup.sh automatically detects the CUDA environment and installs the appropriate PyTorch wheels with GPU support.

Multi-Language Polyglot Environment

To combine multiple programming languages in a single image for polyglot development workflows:

docker build \
  --build-arg BASE_NAMESPACE=labnow \
  --build-arg BASE_IMG=base \
  --build-arg ARG_PROFILE_GO=base \
  --build-arg ARG_PROFILE_RUST=base \
  --build-arg ARG_PROFILE_JULIA=base \
  -t mylab/multi-lang \
  -f docker_core/Dockerfile .

This creates an image with Go, Rust, and Julia toolchains installed side-by-side, useful for comparative development or notebooks requiring multiple kernels.

Customizing Toolchain Versions

To override default versions of language runtimes, pass version environment variables as build arguments:

docker build \
  --build-arg BASE_NAMESPACE=labnow \
  --build-arg BASE_IMG=base \
  --build-arg ARG_PROFILE_JAVA=base,maven \
  --build-arg VERSION_JDK=17 \
  -t mylab/java17 \
  -f docker_core/Dockerfile .

The VERSION_JDK variable instructs the setup_java_base function to install JDK 17 instead of the default JDK 11.

How Profile Selection Works Under the Hood

When you build specific Docker images with custom language profiles, the docker_core/Dockerfile executes a dynamic selection mechanism. The Dockerfile defines build arguments for each supported language, then processes them during the RUN instruction.

As implemented in lines 31-94 of docker_core/Dockerfile, the build process:

  1. Reads the comma-separated values from each ARG_PROFILE_<LANG> argument
  2. Splits the string by commas into individual profile identifiers
  3. Executes the corresponding setup_<lang>_<profile>() function from docker_atom/work/script-setup.sh
  4. Installs packages listed in docker_core/work/install_list_<LANG>_<PROFILE>.{apt,pip,conda} files

If a profile argument is omitted or empty, the loop executes zero times for that language, effectively excluding the runtime from the final image. This modular approach ensures that unused language toolchains do not consume disk space or image layers.

Summary

  • LabNow AI uses a two-layer architecture where docker_base/Dockerfile provides the OS foundation and docker_core/Dockerfile adds language-specific tooling.
  • You build specific Docker images with custom language profiles by passing ARG_PROFILE_<LANG> build arguments with comma-separated profile identifiers.
  • Available profiles include base, datascience, torch, tf2 for Python; base, datascience for R; and similar patterns for Go, Rust, Julia, Java, Node.js, and LaTeX.
  • The build system dynamically executes setup_<lang>_<profile>() functions defined in docker_atom/work/script-setup.sh and installs packages from lists in docker_core/work/.
  • Override default toolchain versions using environment variables like VERSION_JDK, VERSION_PYTHON, etc.

Frequently Asked Questions

What is the difference between docker_base and docker_core?

The docker_base/Dockerfile creates minimal operating system images including Ubuntu variants and CUDA-enabled bases, but contains no programming language toolchains. The docker_core/Dockerfile extends these base images and implements the profile selection logic that installs specific language runtimes and libraries based on your ARG_PROFILE_* build arguments.

Can I combine multiple profiles for the same language?

Yes, you can specify multiple profiles for a single language by providing comma-separated values to the build argument. For example, --build-arg ARG_PROFILE_PYTHON=base,datascience,torch,tf2 installs the base Python runtime, data science libraries, PyTorch, and TensorFlow 2 in a single image.

How do I add custom packages not included in the predefined profiles?

To add packages beyond the predefined profiles, you can extend the docker_core/Dockerfile with additional RUN instructions after the profile setup, or modify the package list files in docker_core/work/ (such as creating install_list_PY_custom.pip) and reference them in custom setup functions added to docker_atom/work/script-setup.sh.

Is GPU support automatically detected when building images?

GPU support is not automatically detected during the build process itself; you must explicitly select a CUDA-enabled base image by setting --build-arg BASE_IMG=nvidia-cuda. However, once you select a GPU base and specify profiles like torch, the setup_python_torch function in docker_atom/work/script-setup.sh automatically detects the CUDA environment and installs the appropriate GPU-enabled PyTorch wheels.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →