Table of Contents
The traditional development environment nowadays consists of many moving pieces. Most of them are there to empower a developer to ship faster while helping companies streamline their processes. DevPod is a solution that helps you create isolated, decelerative, and streamlined development environments that meet the specific needs of the company.
To learn more about DevPod, you can go through the introductory blog on devcontainers and DevPod here.
If you’re using DevPod for your workloads, then a case might arise where you want to have Docker installed on your remote workspace. Here comes the need for a Docker-in-Docker setup. This post shows how you can achieve that in a few simple steps by relying on the manifest that DevPod is built on i.e., devcontainer.json.
About devcontainer.json
The DevContainer.json file represents your workspace and defines all the required extensions, libraries, and programming languages, apart from the development tools. The great thing about DevContainer.json is that you can declaratively define whatever you want in the workspace.
From specific visual studio code extensions to certain tools ready and waiting for you once you spin the workspace.
Moreover, it supports many features, such as the docker container feature. This means you can have features for Docker (DID) support within devcontainer.json by just manipulating your devcontainer.json as we do in this demo.
Setting Up Docker-in-Docker with DevPod
For this demonstration, you will create a basic Python 3.12 environment in your docker-in-docker setup. To execute this, ensure to copy the provided code snippet in your .devcontainer/devcontainer.json
path:
// A Docker-In-Docker devcontainer.json for you to use
{
"name": "Python 3",
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bookworm",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
}
}
The following JSON contains the following keys:
- name: Specifies the name of your development environment.
- image: Defines the Docker image that forms the base of your development environment. Here, mcr.microsoft.com/devcontainers/python:1-3.12-bookworm is used, indicating a Python 3.12 environment.
- features: This section is where you enable additional features for your development environment. In this case, docker-in-docker is enabled by including "ghcr.io/devcontainers/features/docker-in-docker:2": {} which helps you to get Docker in your environment.
Once you've done this, you can proceed to the DevPod UI and reference your local/git repository.
Click on Create Workspace after selecting Provider with your preferred IDE and you will have an environment ready and you can run your docker containers:
You can also click on Open with DevPod here to streamline the flow:
Next Steps
If you want to stay up to date on all the exciting things we're doing, don't miss out on our newsletter. For more:
- Join our Slack Community to keep up-to-date with the latest developments.
- Learn more from our YouTube channel
- Connect with us on Twitter and LinkedIn for more news and giveaways 🕊️
Read through the DevPod Documentation! Love video content more? We got you covered: