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 a base Ubuntu image
- Adds Node.js LTS
- 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/base:ubuntu
- Ubuntu base imagemcr.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 development
Advanced Configuration
Multi-Container Development
For more complex setups, you can define multiple containers using Docker Compose: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:- 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