devcontainer.json file to ensure consistent tools, dependencies, and configurations for all developers.
Benefits
Using Dev Containers with Ona provides several advantages:- Standardized environments across all team members
- Consistent tooling with precisely defined dependency versions
- Isolated Linux VM environments, even when running locally
- Support for both single and multi-container development setups
- Version-controlled configuration that lives with your codebase
- Integration with VS Code and other supported editors
- Separation of development environment from local machine configuration
Configuration
File Location
Place yourdevcontainer.json file in one of these standard locations:
.devcontainer/devcontainer.json.devcontainer.json
Basic Configuration Example
- Uses the Universal image with common languages and tools pre-installed (Node.js, Python, Go, Java, and more)
- Adds Docker-in-Docker support
- Includes ESLint and Prettier VS Code extensions
- Installs the ESLint & PrettierJS plugin for JetBrains IDEs
- Configures auto-formatting on save
- Forwards ports 3000 and 8080
Multiple Dev Container configurations
You can manage multiple Dev Container configurations using Ona projects. This allows you to define different environments for:- Different branches or repositories
- Various development scenarios
- Specialized tasks requiring specific tools
Known limitations
When using Dev Containers with Ona, be aware of these limitations:- Platform-specific features may not work with Ona Desktop
- Conflicting features can cause build failures (Ona will display an error message)
- Some Dev Container commands might behave differently in Ona’s environment
- When build errors occur, recovery mode is engaged, requiring manual intervention
Recommended images
Microsoft provides well-maintained Dev Container base images for popular development stacks:mcr.microsoft.com/devcontainers/universal:4.0.1-noble- Full-featured image with common languages and toolsmcr.microsoft.com/devcontainers/javascript-node- Node.js developmentmcr.microsoft.com/devcontainers/python- Python developmentmcr.microsoft.com/devcontainers/dotnet- .NET developmentmcr.microsoft.com/devcontainers/java- Java developmentmcr.microsoft.com/devcontainers/go- Go developmentmcr.microsoft.com/devcontainers/base:ubuntu- Minimal image
Advanced configuration
Using secrets during builds
Organization and project secrets can be used during Dev Container image builds via secret mounts. This is useful when your Dockerfile needs to authenticate with private package registries, pull licensed dependencies, or access credentials that should not be baked into the final image. Secrets are not exposed by default. EachRUN instruction in your Dockerfile must explicitly request the secrets it needs using the --mount=type=secret flag. The mounted secret itself is only available for the duration of that RUN step and is not included in the image layer.
User secrets are not available during builds. Built images are cached and shared across the project when the Dev Container image cache is enabled, so personal credentials in a build could be exposed to other team members.
Build-time secret mounts require a Dockerfile-based Dev Container (
build.dockerfile or dockerFile in devcontainer.json). Docker Compose-based Dev Containers are not yet supported.How to reference a secret
Theid in --mount=type=secret,id=... must match how the secret is configured in Ona. For file secrets, the id is the full file path. For environment variable secrets, the id is the variable name.
Use target= to control where the secret is mounted during the RUN step. The target path can be any location your build step needs — it does not have to match the id.
Example: private npm registry (file mount)
Given a file secret configured in Ona at/usr/local/secrets/npm-token:
.npmrc file is written, used for npm ci, and removed within the same RUN step so the token is not persisted in the image layer.
Example: private npm registry (env mount)
Theenv= option mounts the secret directly as an environment variable, avoiding the need to read from a file. This requires Dockerfile syntax v1.10.0+, so you must add # syntax=docker/dockerfile:1 as the very first line of your Dockerfile (before any other instructions or comments):
devcontainer.json are needed. Ona passes the secrets to the build process, and your Dockerfile controls which RUN steps can access them.
Multi-Container Development
For more complex setups, you can define multiple containers using Docker Compose. devcontainer.json:Adding Custom Features
Dev Container Features are self-contained, shareable units of installation code and configuration that let you quickly add tooling, runtimes, or libraries to your development container. You can add features to your Dev Container by adding them to thefeatures section of your devcontainer.json file:
- Community-supported features might require additional testing, as they may have been developed without specific consideration for compatibility.
- Feature behavior can vary depending on base images, other installed features, and specific configurations in your setup.
Troubleshooting
If your Dev Container fails to build:- Use the “Ask Ona” button - When a devcontainer build fails, click the “Ask Ona” button in the startup accordion to get AI-powered help diagnosing and fixing the issue. Ona will analyze the error logs and suggest solutions for common problems like privileged operations, sudo commands, or image pull failures. This feature is available when Ona AI is enabled and your runner supports LLM capabilities.
- Check the Ona console for specific error messages
- Ensure image versions are correctly specified
- Try rebuilding in recovery mode to debug the issue
Next steps
- Explore the full Dev Container specification for advanced configurations
- Check out the Dev Container Feature catalog for additional tools and utilities
- Learn about Ona projects to manage multiple environments