Overview

Environment configuration lets you define the default environment that all agents will start from when working on your project. Instead of using the generic Ubuntu environment, you can specify exactly what base image, dependencies, and setup your project needs.

Configuration applies to new environments only. Existing environments will continue using their original setup.

When to Configure Environments

Consider customizing your environment when:

  • Your project requires a specific language runtime (Python, Node.js, Go, etc.)
  • You need specific system packages or tools installed
  • You want consistent development dependencies across all agent sessions
  • Your project has a complex setup process that should be automated

Default vs Configured

Default: Basic Ubuntu 24.04 with essential tools (git, curl, build tools)

Configured: Your specified base image + automated setup commands + environment variables

Quick Start

Set up a Python project environment:

# Set the base image to Python 3.11
container-use config base-image set python:3.11

# Add setup commands for your project
container-use config setup-command add "pip install -r requirements.txt"
container-use config setup-command add "pip install pytest black flake8"

# Set environment variables
container-use config env set PYTHONPATH /workdir
container-use config env set DEBUG true

# View your configuration
container-use config show

Now all new agent environments will start with Python 3.11, your dependencies pre-installed, and environment variables configured.

Base Image Configuration

The base image is the foundation of your environment - the container image that everything else builds on top of.

Setting a Base Image

# Popular base images
container-use config base-image set python:3.11
container-use config base-image set node:18
container-use config base-image set golang:1.21
container-use config base-image set ubuntu:22.04

# With specific tags for reproducibility
container-use config base-image set python:3.11.9-slim
container-use config base-image set node:18.19.0-alpine

Viewing Current Base Image

container-use config base-image get
# Output: python:3.11

Resetting to Default

container-use config base-image reset
# Resets to ubuntu:24.04
container-use config base-image set python:3.11
container-use config setup-command add "pip install -r requirements.txt" ```
</Tab>
<Tab title="🟢 Node.js Projects">
```bash
container-use config base-image set node:18
container-use config setup-command add "npm install"

Setup Commands

Setup commands are shell commands that run when creating a new environment, after the base image is ready but before the agent starts working.

Adding Setup Commands

# Install project dependencies
container-use config setup-command add "pip install -r requirements.txt"

# Install development tools
container-use config setup-command add "pip install pytest black flake8"

# Run custom setup scripts
container-use config setup-command add "./scripts/dev-setup.sh"

# Multiple commands with &&
container-use config setup-command add "apt update && apt install -y postgresql-client"

Managing Setup Commands

# List all setup commands
container-use config setup-command list

# Remove a specific command
container-use config setup-command remove "pip install pytest black flake8"

# Clear all setup commands
container-use config setup-command clear

Setup Command Best Practices

Environment Variables

Environment variables are set in all new environments and can be used to configure your application, development tools, and runtime behavior.

Setting Environment Variables

# Set common development variables
container-use config env set DEBUG true
container-use config env set LOG_LEVEL debug

# Configure application paths
container-use config env set PYTHONPATH /workdir
container-use config env set PATH /usr/local/bin:/workdir/bin:$PATH

# Set API keys and configuration
container-use config env set API_URL https://api.example.com
container-use config env set REDIS_URL redis://localhost:6379

Managing Environment Variables

# List all environment variables
container-use config env list

# Remove a specific variable by key
container-use config env unset DEBUG

# Clear all environment variables
container-use config env clear

Environment Variable Best Practices

Secrets

Secrets allow your agents to access API keys, database credentials, and other sensitive data securely. Secrets are resolved within the container environment - agents can use your credentials without the AI model ever seeing the actual values.

Complete Secrets Guide

Learn about all secret types, configuration commands, and examples

Common Configuration Patterns

Full-Stack Web Application

# Node.js + PostgreSQL client
container-use config base-image set node:18
container-use config setup-command add "npm install"
container-use config setup-command add "apt update && apt install -y postgresql-client"
container-use config setup-command add "npm run build"
container-use config env set NODE_ENV development
container-use config env set DEBUG true

Data Science Project

# Python with scientific computing
container-use config base-image set python:3.11
container-use config setup-command add "pip install -r requirements.txt"
container-use config setup-command add "pip install jupyter pandas numpy matplotlib"
container-use config setup-command add "python -m ipykernel install --user --name=myproject"
container-use config env set PYTHONPATH /workdir
container-use config env set JUPYTER_CONFIG_DIR /workdir/.jupyter

Microservice Development

# Go with build tools
container-use config base-image set golang:1.21
container-use config setup-command add "go mod download"
container-use config setup-command add "go install github.com/air-verse/air@latest"
container-use config setup-command add "apt update && apt install -y curl jq"
container-use config env set CGO_ENABLED 0
container-use config env set GOOS linux

Legacy Application

# Specific Ubuntu version with custom setup
container-use config base-image set ubuntu:20.04
container-use config setup-command add "apt update && apt install -y python2.7 python-pip"
container-use config setup-command add "pip2 install -r legacy-requirements.txt"
container-use config setup-command add "./scripts/legacy-setup.sh"
container-use config env set PYTHONPATH /workdir
container-use config env set LEGACY_MODE true

Viewing Your Configuration

See your complete environment configuration:

container-use config show

Example output:

Base Image:            python:3.11
Workdir:               /workdir
Setup Commands:
  1.                   pip install -r requirements.txt
  2.                   pip install pytest black flake8
  3.                   ./scripts/dev-setup.sh
Environment Variables:
  1.                   PYTHONPATH=/workdir
  2.                   DEBUG=true
  3.                   LOG_LEVEL=info

How Configuration Works

Understanding the environment creation process:

1

Environment Creation Triggered

Agent requests a new environment for your project

2

Base Image Loaded

Container starts from your configured base image (or ubuntu:24.04 default)

3

Source Code Mounted

Your project files are made available in the container at /workdir

4

Environment Variables Set

All configured environment variables are made available in the container

5

Setup Commands Execute

Each setup command runs in order, with any failures stopping the process

6

Agent Begins Work

Agent starts working in the fully configured environment

Configuration Storage

Your environment configuration is stored in .container-use/environment.json in your project root:

{
  "base_image": "python:3.11",
  "setup_commands": [
    "pip install -r requirements.txt",
    "pip install pytest black flake8"
  ],
  "env": ["PYTHONPATH=/workdir", "DEBUG=true", "LOG_LEVEL=info"],
  "workdir": "/workdir"
}

Version Control

Commit your .container-use/ directory to share environment configuration with your team. Everyone will get the same environment setup.

Troubleshooting

Setup Command Failures

If a setup command fails, the environment creation stops:

# Check what went wrong
container-use log <environment-id>

# Common fixes:
# 1. Fix the command and try again
container-use config setup-command remove "broken-command"
container-use config setup-command add "fixed-command"

# 2. Add missing dependencies
container-use config setup-command add "apt update && apt install -y missing-package"

Base Image Issues

If your base image doesn’t work:

# Reset to default and try again
container-use config base-image reset
container-use config show

# Or try a different image
container-use config base-image set python:3.11-slim

Configuration Not Taking Effect

Remember that configuration only applies to new environments:

# Delete old environment and create new one
container-use delete <old-environment-id>
# Start new agent session - will use new configuration

Next Steps