You can add the following line to your .devcontainer.json and it will set it up for you:

    // Allow the devcontainer to run host docker commands, see https://github.com/devcontainers/templates/tree/main/src/docker-outside-of-docker
    "features": {
        "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
    }

This uses "Devcontainer Features", which add common language/tool/CLI to a development container. You will have the docker CLI installed, and it will point to the existing docker daemon on your host.

Answer from Jethro on Stack Overflow
🌐
Ken Muse
kenmuse.com › blog › docker-from-docker-in-alpine-dev-containers
Docker-from-Docker in Alpine Dev Containers - Ken Muse
January 5, 2023 - To keep things simple, I chose to use the Docker-from-Docker pattern. This allowed me to use my host’s Docker environment, which includes x86 emulation support. It was also significantly less effort to setup! 😄 ... In the Dockerfile file, include sudo apk add docker-cli to ensure that the Docker CLI is installed in the Alpine container. In the devcontainer.json, mount the Docker socket so that it is available to the CLI using "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ]. This makes the Unix socket that the Docker daemon listens on available inside the container.
🌐
Docker
docker.com › blog › streamlining-local-development-with-dev-containers-and-testcontainers-cloud
Streamlining Local Development with Dev Containers and Testcontainers Cloud | Docker
September 18, 2024 - Navigate to devcontainer.json and click on the Dev Containers plugin and select Create Dev Container and Clone Sources. The New Dev Container window will open (Figure 4). Figure 4: New Dev Container window. In the New Dev Container window, you can select the Git branch and specify where to create your dev container. By default, it uses the local Docker instance, but you can select the ellipses (…) to add additional Docker servers from the cloud or WSL and configure the connection via SSH...
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › containers
Developing inside a Container
November 3, 2021 - You can use the GitHub Action in the devcontainers/ci repository to help you reuse dev containers in your workflows. Go to the dev container CLI article on pre-building images for more information. You can include Dev Container configuration and Feature metadata in prebuilt images via image labels. This makes the image self-contained since these settings are automatically picked up when the image is referenced - whether directly, in a FROM in a referenced Dockerfile, or in a Docker Compose file.
🌐
Reddit
reddit.com › r/docker › devcontainers: "docker in docker" or "docker outside of docker"?
r/docker on Reddit: Devcontainers: "Docker in Docker" or "Docker outside of Docker"?
February 3, 2024 -

Hi everyone,

I want to build a devcontainer so that we have a standard development environment for our team.

In our project, we are using an Nx monorepo that contains two apps: a NextJS frontend and a NestJS backend. We are also intending on using a Postgres Database.

We intend to have everything be deployed as containers in the end, by using Docker and Docker-Compose to help set up our services. But we would like to be able to use Docker while we are developing, for example, we want to test with dummy data from our Postgres DB that is in a container, and also we want to have the sense of what the production environment is like while we are in development.

I would also need to set up a script that once I run Docker Compose that I would have Nx watching for any changes, and then trigger a rebuild of the respective Docker container so that the containers have the latest changes or something, or perhaps I would use a shared volume.

I was going over the given templates in VS Code, and I noticed two options: "Docker in Docker" and "Docker outside of Docker."

I get the idea of what each of them mean, but I want to ask which one is better for my use case? And I also want to ask if the approach I am using for hot-reloading my Docker containers is fine or what does the community recommend?

Thanks! :)

🌐
Development Containers
containers.dev › guide › dockerfile
Using Images, Dockerfiles, and Docker Compose
This corresponds to a sub-folder under the mount point from ../..:/workspaces:cached in the docker-compose.yml file. That’s it! You can also combine these scenarios and use Dockerfile with Docker Compose. This time we’ll update docker-compose.yml to reference the Dockerfile by replacing image with a similar build section: version: '3.8' services: devcontainer: build: context: .
🌐
GitHub
github.com › microsoft › vscode-dev-containers › blob › main › containers › docker-in-docker › README.md
vscode-dev-containers/containers/docker-in-docker/README.md at main · microsoft/vscode-dev-containers
This definition's approach creates pure "child" containers by hosting its own instance of the docker daemon inside this container. This is compared to the forementioned "docker-from-docker" method (sometimes called docker-outside-of-docker) that bind mounts the host's docker socket, creating "sibling" containers to the current container.
Author   microsoft
🌐
GitHub
github.com › microsoft › vscode-dev-containers › blob › main › script-library › docs › docker-in-docker.md
vscode-dev-containers/script-library/docs/docker-in-docker.md at main · microsoft/vscode-dev-containers
You should update dind-var-lib-docker with a unique name for your container to avoid corruption when multiple containers write to it at the same time. While technically optional, --init enables the tini init process to properly handle signals and ensure Zombie Processes are cleaned up. If you want any containers or volumes you create inside the container to survive it being deleted, you can use a "named volume". And the following to .devcontainer/devcontainer.json if you are referencing an image or Dockerfile replacing dind-var-lib-docker with a unique name for your container:
Author   microsoft
Find elsewhere
🌐
GitHub
github.com › devcontainers › features › tree › main › src › docker-outside-of-docker
features/src/docker-outside-of-docker at main · devcontainers/features
Feature invokes a script to enable using a forwarded Docker socket within a container to run Docker commands. "features": { "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} }
Author   devcontainers
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › create-dev-container
Create a Dev Container
November 3, 2021 - Docker-Outside-of-Docker Compose - Includes the Docker CLI and illustrates how you can use it to access your local Docker install from inside a dev container by volume mounting the Docker Unix socket. After you make your selection, VS Code will add the appropriate .devcontainer/devcontainer.json (or .devcontainer.json) file to the folder.
🌐
Medium
medium.com › agoda-engineering › container-based-development-how-to-setup-development-in-docker-with-dev-container-8b3e9d1e065e
Container-based Development: How to Setup Development in Docker with Dev Container | by Agoda Engineering | Agoda Engineering & Design | Medium
September 12, 2023 - The configuration file is either located under the .devcontainer folder or stored as a .devcontainer.json file in the root of your project. You can update the configuration to do things such as: Install additional tools. Install VS Code extensions. Expose ports from container.
🌐
Medium
medium.com › versent-tech-blog › introduction-to-dev-containers-4c01cb1752a0
Introduction to Dev Containers. An introduction to Dev Containers in… | by Mathew Hemphill | Versent Tech Blog | Medium
June 19, 2024 - { "name": "Java Development", "image": ... [ "vscjava.vscode-java-pack" ] } } } This configures a container (named “Java Development”) based on an image provided by Microsoft on Docker Hub....
🌐
Cloudomation
cloudomation.com › home › blog › blog › devfile & devcontainer vs. dockerfile & docker-compose
Devfile & devcontainer vs. Dockerfile & Docker-Compose
May 22, 2025 - The Docker-compose file can reference container images in a container registry, or reference Dockerfiles to build the containers from scratch. Devfile and devcontainer provide yet another layer on top, which allows you to describe a full development environment.
🌐
Docker Hub
hub.docker.com › r › microsoft › vscode-devcontainers
microsoft/vscode-devcontainers - Docker Image
You may need to choose the From a predefined container configuration definition... option if your project has an existing Dockerfile or Docker Compose file. Answer any questions that appear. See the definition's README for configuration options. A link is available in the .devcontainer/devcontainer.json file added to your folder.
🌐
GitHub
docs.github.com › en › codespaces › setting-up-your-project-for-codespaces › adding-a-dev-container-configuration › introduction-to-dev-containers
Introduction to dev containers - GitHub Docs
To use a Dockerfile as part of a dev container configuration, reference it in your devcontainer.json file by using the dockerfile property. ... Various options are available to you if you want to use existing container orchestration in your ...
🌐
GitHub
github.com › orgs › devcontainers › packages › container › features › docker-outside-of-docker › 436066331
features/docker-outside-of-docker versions · devcontainers · GitHub
June 11, 2025 - It translates the command line ..."text\":\"This dev container includes the Docker CLI (`docker`) pre-installed and available on the `PATH` for running and managing containers using the Docker daemon on the host machine.\"}]}}},\...
🌐
Development Containers
containers.dev › features
Available Dev Container Features
Development containers documentation and specification page.
🌐
GitHub
github.com › devcontainers › features › issues › 742
`docker-outside-of-docker` not working (Windows 11) · Issue #742 · devcontainers/features
November 3, 2023 - My understanding was that docker-outside-of-docker would allow me to access and control containers running on my host machine. I have everything installed, but my DevContainer cannot see any containers running on my host machine.
Author   Minituff
🌐
Development Containers
containers.dev › implementors › json_reference
Dev Container metadata reference
Instead, container orchestrator formats can be referenced when needed to manage multiple containers and their lifecycles. Today, devcontainer.json includes scenario specific properties for working without a container orchestrator (by directly referencing an image or Dockerfile) and for using Docker Compose as a simple multi-container orchestrator.