# DevPod Development Environments

> DevPod for codespace-like development.

- Category: Development Tools
- Difficulty: intermediate
- Components: devpod-provider, registry
- Tags: devpod, devcontainer, codespaces, remote-dev
- Source: https://docker.recipes/development/devpod-stack

## Overview

DevPod is an open-source client-only tool that creates reproducible developer environments on any backend, inspired by GitHub Codespaces but with vendor independence. The loftsh/devpod-provider-docker component acts as a Docker-based provider that enables DevPod to spawn development containers using local Docker infrastructure, while the Docker Registry provides a private repository for storing and managing development container images. This combination creates a self-hosted alternative to cloud-based development environments like GitHub Codespaces or GitPod. The stack operates by having the DevPod provider interface with the local Docker daemon to create isolated development containers based on devcontainer.json specifications, while the registry component ensures fast access to custom base images and reduces external dependencies. This setup appeals to development teams requiring full control over their development infrastructure, organizations with strict data sovereignty requirements, or developers working in air-gapped environments where external codespace services aren't accessible.

## Features

- Docker provider backend for creating reproducible dev containers using devcontainer.json specifications
- Private Docker registry for caching and storing custom development environment images
- Privileged container access enabling nested Docker operations and system-level development
- DevPod CLI integration supporting workspace creation, management, and SSH access
- Docker socket mounting for direct container orchestration and Docker-in-Docker scenarios
- VS Code integration through DevPod extension for direct IDE connectivity
- Vendor-agnostic development environment provisioning independent of cloud providers
- Local development container caching reducing startup times for repeated environments

## Use cases

- Creating standardized development environments for distributed teams working on containerized applications
- Establishing secure development sandboxes in enterprise environments with strict network policies
- Building custom development toolchains with pre-configured language runtimes and debugging tools
- Testing application behavior across different development container configurations locally
- Providing consistent development environments for open-source projects with complex dependencies
- Setting up isolated development workspaces for client projects requiring different tooling versions
- Creating reproducible bug reproduction environments that match production container specifications

## Prerequisites

- Docker Engine 20.10+ with Docker Compose v2 support
- DevPod CLI installed on local development machine
- Minimum 4GB available RAM for concurrent development containers
- Understanding of devcontainer.json specification and VS Code development containers
- Basic knowledge of Docker registry operations and image management
- Port availability: 8080 for DevPod provider API and 5000 for Docker registry

## docker-compose.yml

```yaml
services:
  devpod-provider:
    image: loftsh/devpod-provider-docker:latest
    container_name: devpod-provider
    restart: unless-stopped
    privileged: true
    ports:
      - "${PROVIDER_PORT:-8080}:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - devpod_data:/var/lib/devpod

  registry:
    image: registry:2
    container_name: devpod-registry
    restart: unless-stopped
    ports:
      - "${REGISTRY_PORT:-5000}:5000"
    volumes:
      - registry_data:/var/lib/registry

volumes:
  devpod_data:
  registry_data:
```

## .env

```bash
# DevPod
PROVIDER_PORT=8080
REGISTRY_PORT=5000
```

## Usage notes

- Install DevPod CLI locally
- Use devcontainer.json specs
- Local registry for images
- VS Code integration available

## Troubleshooting

- DevPod provider fails to start containers: Verify Docker socket permissions and ensure Docker daemon is accessible from within the provider container
- Registry push/pull operations timeout: Check registry_data volume permissions and ensure sufficient disk space for image storage
- VS Code cannot connect to DevPod workspace: Confirm DevPod provider is accessible on port 8080 and SSH keys are properly configured
- Development containers cannot access Docker daemon: Verify privileged flag is enabled for devpod-provider service and Docker socket is mounted correctly
- DevPod workspace creation hangs during image pull: Check registry connectivity and verify custom images exist in the local registry with correct tags
- Permission denied errors in development containers: Ensure user namespace mapping is configured correctly in devcontainer.json and container runs with appropriate user permissions

