Devcontainer Configuration
This directory contains the VS Code devcontainer configuration for Roslyn-Stone development.
Features
- Base Image: Official Microsoft .NET devcontainer with .NET SDK 10.0
- Docker-in-Docker: Docker feature enabled via devcontainer features
- VS Code Extensions: Pre-configured C# development tools
- Non-root User: Development as
vscodeuser with Docker access - .NET Configuration: Optimized environment variables for development
Docker-in-Docker Support
The devcontainer includes the docker-in-docker feature which provides full Docker support, allowing you to:
- Build Docker images from within the container
- Run Docker containers for testing
- Test containerized deployments of Roslyn-Stone
- Develop and test Docker-based workflows
Testing Docker-in-Docker
After opening the project in the devcontainer, verify Docker is working:
# Check Docker is available
docker --version
# Run a test container
docker run --rm hello-world
# Build and run a test image
echo 'FROM alpine:latest' > /tmp/Dockerfile.test
echo 'CMD ["echo", "Docker-in-Docker is working!"]' >> /tmp/Dockerfile.test
docker build -t dind-test -f /tmp/Dockerfile.test /tmp
docker run --rm dind-test
docker rmi dind-test
Quick Start
- Open this repository in VS Code
- Install the "Dev Containers" extension if not already installed
- Press
F1and select "Dev Containers: Reopen in Container" - Wait for the container to build and the project to restore
- Start developing!
Configuration Details
Dockerfile
The Dockerfile:
- Uses
mcr.microsoft.com/devcontainers/dotnet:1-10.0as the base image (includes .NET 10.0 SDK) - Base image already includes the
vscodeuser and common development tools - Docker will be installed by the docker-in-docker feature from
devcontainer.json - Minimal and clean - relies on official Microsoft devcontainer images
devcontainer.json
The devcontainer configuration:
- Uses the docker-in-docker feature for full Docker support
- Runs the container as the
vscodeuser - Sets .NET environment variables to optimize development experience
- Configures VS Code extensions for C#, Docker, and GitHub integration
- Runs
dotnet restore && dotnet buildafter container creation
Environment Variables
The following .NET environment variables are configured:
DOTNET_CLI_TELEMETRY_OPTOUT=1- Disables telemetryDOTNET_GENERATE_ASPNET_CERTIFICATE=0- Skips HTTPS dev certificateDOTNET_NOLOGO=1- Suppresses .NET logo outputDOTNET_USE_POLLING_FILE_WATCHER=1- Uses polling for file watching (better for containers)
Post-Create Command
The devcontainer automatically runs dotnet restore && dotnet build after creation to ensure the project is ready for development.
Customization
Adding VS Code Extensions
Edit the extensions array in devcontainer.json:
"customizations": {
"vscode": {
"extensions": [
"your.extension.id"
]
}
}
Adding System Packages
Edit the Dockerfile to install additional packages:
RUN apt-get update && apt-get install -y \
your-package-name \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
Adding .NET Tools
Install tools in the post-create command or manually after container starts:
dotnet tool install -g your-tool-name
Troubleshooting
Docker-in-Docker Not Working
If Docker commands fail inside the container:
- Ensure Docker is running on your host machine
- Check that the docker-in-docker feature is enabled in
devcontainer.json - Try rebuilding the container: "Dev Containers: Rebuild Container"
- Check Docker daemon status:
sudo service docker statusordocker info - Verify the
vscodeuser has Docker access:groups(should includedocker)
Build Failures
If the post-create command fails:
- Check internet connectivity
- Verify NuGet feeds are accessible
- Manually run
dotnet restoreand check for errors - Review the devcontainer creation logs
Permission Issues
If you encounter permission issues with Docker:
- Verify the
vscodeuser is in thedockergroup:groups - Rebuild the container to ensure the docker-in-docker feature is properly configured
- Try restarting the Docker daemon if needed