This document explains how to deploy and use Postal in Docker containers.
Postal provides Docker support through a pre-built container image that includes all dependencies and configuration for running the AI coding agent in containerized environments.
- Build and start the container
cd docker
API_KEY="your_openrouter_api_key" docker-compose up -d- Connect to your workspace
The container mounts your current directory ($POSTAL_WORKSPACE:-..) as /workspace inside the container. You can now interact with your code through Postal.
- Build the image
docker build -t postal:dev ..- Run the container
docker run -d \
--name postal \
-v "$(pwd):/workspace" \
-v "$(pwd)/.postal:/config" \
-e API_KEY="your_openrouter_api_key" \
postal:dev| Variable | Description | Default |
|---|---|---|
API_KEY |
OpenRouter API key for authentication | - |
BASE_URL |
Custom API base URL (optional) | - |
TERM |
Terminal type (for proper coloring) | xterm-256color |
- Host:
${POSTAL_WORKSPACE:-..}(current directory by default) - Container:
/workspace - Purpose: Project directory containing your code to be modified by Postal
- Host:
.postal/(relative to project root) - Container:
/config - Purpose: Postal configuration files, including
~/.config/postal/config.toml(user-wide) and.postal/config.toml(project-specific)
-
API Key: You need an OpenRouter API key to use Postal. Get one at openrouter.ai
-
Installation: Install the
postalclipackage locally first (outside containers):
pip install postalcli- Authentication: Run
postal loginonce to authenticate with OpenRouter (opens browser OAuth) orpostal login --pasteto paste API key directly
- The container's working directory is
/workspace - Changes made by Postal will be reflected in your host machine through the volume mapping
- Ensure you have proper file system permissions for write operations
- User configuration (
~/.config/postal/) is persisted in the.postalvolume - Project-specific configuration (
.postal/) is mounted from your project directory - API keys and other sensitive data should be managed carefully in container environments
Once the container is running, you can interact with Postal:
docker exec -it postal postal "your prompt here"- Start your container with
docker-compose up -d - Execute interactive sessions with
docker exec -it postaland pass prompts to Postal - Monitor changes in your workspace directory
- Ensure the
postalclipackage is installed in the container - This is handled automatically in the Docker build process
- Check file permissions in your workspace directory
- The container user may need write access to files
- Verify your
.postal/config.tomlfile exists with proper settings - User authentication may need to be done outside the container
To inspect container state and logs:
docker ps
docker logs postal
docker exec -it postal bashdocker-compose down
# Or for direct Docker usage:
docker stop postal
docker rm postal- Use
docker loginto pull images from private registries - Consider using environment-specific Dockerfiles for production deployments
- Implement proper API key management (Kubernetes secrets, environment variables)
- For better performance, mount your workspace directory with appropriate caching (e.g., Docker volumes)
- Consider using Docker Compose's
syncservice for faster development iteration
- Monitor container resource usage with
docker stats postal - Consider implementing logging to a centralized system
The base Dockerfile in docker/Dockerfile can be extended for custom requirements:
FROM postal:latest
USER root
RUN apt-get update && apt-get install -y some-package
USER appuserFor optimized production builds:
FROM postal:latest AS production
# Production-specific optimizationsExpose Postal to external networks:
services:
postal:
ports:
- "8080:80" # If using a web interface- Main project README:
../README.md - Docker reference documentation: Look at the main README for installation and usage
- Configuration options: Check
~/config/postal/config.tomlfor available settings
For issues with Docker deployment, refer to the main project issues or documentation.
This documentation is auto-generated based on the current Docker configuration.
Dockerfile: Container build specificationdocker-compose.yml: Docker Compose configuration../pyproject.toml: Project dependencies and build configuration