Dev Containers
Dev containers allow you to develop inside Docker or Podman containers with pre-configured development environments. Zed automatically detects dev container configurations and can connect to running containers.Overview
Dev containers provide:- Consistent environments across team members
- Isolated dependencies without affecting your host system
- Pre-configured toolchains specific to each project
- Reproducible builds with versioned container images
Quick Start
- Create a
.devcontainerfolder or.devcontainer.jsonfile in your project - Define your container configuration (see Configuration)
- Zed will prompt you to open the project in a container when it detects the configuration
- Alternatively, use the “Open Dev Container” command to manually connect
Configuration
Basic Configuration
Create.devcontainer/devcontainer.json in your project:
Using a Dockerfile
Build a custom image from a Dockerfile:Dockerfile:
Docker Compose
Use Docker Compose for multi-container setups:docker-compose.yml:
Connection Methods
Automatic Detection
Zed detects dev container configurations when you open a project. A notification prompts you to reopen the project in a container. To disable automatic prompts, add this to your settings:Manual Connection
- Open the command palette:
Cmd+Shift+P(macOS) orCtrl+Shift+P(Linux/Windows) - Search for “Open Dev Container”
- Select your project from the list
Command Line
Open a project in a dev container directly:Docker vs Podman
Zed supports both Docker and Podman as container runtimes.Using Docker (Default)
No additional configuration needed. Zed usesdocker on your PATH.
Using Podman
Configure Podman in your connection settings. Create a custom connection in~/.config/zed/settings.json:
Container Configuration Options
DevContainer.json Reference
Key properties supported by Zed:Property Descriptions
name: Display name for the containerimage: Base container image to usebuild: Build a custom image from a DockerfileworkspaceFolder: Path inside container where project is mountedworkspaceMount: Custom mount configuration for the workspacemounts: Additional bind mounts or volumesremoteUser: User account inside the container (default: root)containerEnv: Environment variables set in the containerremoteEnv: Environment variables for remote operationsfeatures: Dev container features to install (pre-built tools)customizations.zed: Zed-specific settings and extensions
Remote Dev Containers
Combine SSH remote development with dev containers:- Connect to a remote server via SSH (see SSH Remote Development)
- Open a project on the remote server
- Configure a dev container in that project
- Zed will use Docker/Podman on the remote server
- Use powerful remote hardware for containers
- Share containers across team members
- Isolate development from your local machine
Configuration Example
SSH connection insettings.json:
Container Lifecycle
Starting Containers
When you connect to a dev container, Zed:- Checks if a container with the configuration exists
- Builds the image if needed (from Dockerfile or pulls base image)
- Starts the container if not running
- Uploads the Zed remote server binary to the container
- Connects to the container and opens your project
Stopping Containers
Containers persist after closing Zed. To stop manually:Rebuilding Containers
After changing yourdevcontainer.json or Dockerfile:
- Stop and remove the old container:
- Reconnect in Zed to build and start a new container
Working with Containers
File Synchronization
Your project files are mounted into the container:- Changes made in Zed are immediately visible in the container
- Files created in the container appear in Zed
- Use
.gitignoreto exclude generated files
Terminals
Terminals opened in Zed run inside the container:- Full access to container’s filesystem
- Environment variables from
containerEnvandremoteEnv - Run build commands with container’s toolchain
Language Servers
Language servers run inside the container:- Install language servers in your container image
- Or use dev container features to install them automatically
- Zed extensions are propagated to the container
Tasks
Zed tasks execute inside the container:Port Forwarding
Forward ports from the container to your local machine:In devcontainer.json
In SSH Connection Settings
For remote containers, configure port forwarding in the SSH connection:Dev Container Features
Features are pre-packaged tools and runtimes. Common features:Node.js
Python
Git
Docker-in-Docker
Zed-Specific Customizations
Extensions
Install Zed extensions in the container:Settings
Apply Zed settings in the container:Troubleshooting
Container Fails to Start
- Check Docker/Podman: Ensure the container runtime is installed and running
- View logs: Run
docker logs <container-id>orpodman logs <container-id> - Test image manually:
docker run -it <image> /bin/bash - Check permissions: Ensure your user can access Docker socket
Binary Upload Fails
- Ensure user exists: The
remoteUsermust exist in the container - Check permissions: The user needs write access to the home directory
- Verify platform: Container must run on a supported architecture (x86_64 or ARM64)
Language Server Issues
- Install in container: Language servers must be installed in the container image
- Check PATH: Ensure language servers are on the container’s PATH
- Use features: Dev container features can install common language servers
Performance Problems
- Use volumes: Avoid bind mounts for large dependencies (use Docker volumes)
- Limit mounts: Only mount necessary directories
- Check resources: Ensure Docker has sufficient CPU and memory allocated
Port Forwarding Not Working
- Check container ports: Use
docker psto verify published ports - Verify firewall: Ensure ports are not blocked by firewall rules
- Test locally: Try
curl localhost:<port>on the host
Best Practices
Container Image Design
- Use official base images for stability
- Pin image versions for reproducibility
- Create a non-root user for security
- Install dependencies in layers for faster rebuilds
Configuration Management
- Commit
.devcontainerfolder to version control - Document any manual setup steps in README
- Use features for common dependencies
- Test container builds on different machines
Security
- Avoid running as root user
- Don’t commit secrets in Dockerfile or devcontainer.json
- Use build arguments for sensitive values
- Limit bind mounts to necessary directories
Performance
- Use volumes for node_modules, cargo target, etc.
- Exclude large generated directories from workspace mount
- Keep container images small
- Use multi-stage Dockerfiles for smaller images
