Skip to content
Branch: master
Find file History
Type Name Latest commit message Commit time
Failed to load latest commit information.
.devcontainer Add iproute2 to avoid warnings about "ip" command not being found Aug 9, 2019
.npmignore .npmignore Apr 10, 2019 Update Docker extension ID, formatting Jul 10, 2019

Docker in Docker


Access your local Docker install from inside a dev container. Installs Docker extension in the container along with needed CLIs.

Metadata Value
Contributors The VS Code team
Definition type Dockerfile
Languages, platforms Any

Note: There is also a Docker Compose variation of this same definition.


Dev containers can be useful for all types of applications including those that also deploy into a container based-environment. While you can directly build and run the application inside the dev container you create, you may also want to test it by deploying a built container image into your local Docker Desktop instance without affecting your dev container.

This example illustrates how you can do this by running CLI commands and using the Docker VS Code extension right from inside your dev container. It installs the Docker extension inside the container so you can use its full feature set with your project.

How it works / adapting your existing dev container config

You can adapt your own existing development container Dockerfile to support this scenario by following these steps:

  1. First, install the Docker CLI in your container. From .devcontainer/Dockerfile:

    RUN apt-get update \
        # Install Docker CE CLI
        && apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release \
        && curl -fsSL$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null \
        && add-apt-repository "deb [arch=amd64]$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" \
        && apt-get update \
        && apt-get install -y docker-ce-cli
        # Install Docker Compose
        && curl -sSL "$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \
        && chmod +x /usr/local/bin/docker-compose
  2. Then just forward the Docker socket by mounting it in the container using runArgs. From .devcontainer/devcontainer.json:

    "runArgs": ["-v","/var/run/docker.sock:/var/run/docker.sock"]
  3. Finally, update devcontainer.json to force the Docker extension to be installed inside the container instead of locally. From .devcontainer/devcontainer.json:

    "settings": {
        "remote.extensionKind": {
            "ms-azuretools.vscode-docker": "workspace"
  4. Press F1 and run Remote-Containers: Rebuild Container so the changes take effect.

That's it!

Using this definition with an existing folder

There are no special setup steps are required, but note that the included .devcontainer/Dockerfile can be altered to work with other Debian/Ubuntu-based container images such as node or python. Just, update the FROM statement to reference the new base image. For example:

FROM node:lts

Beyond that, just follow these steps to use the definition:

  1. If this is your first time using a development container, please follow the getting started steps to set up your machine.

  2. To use VS Code's copy of this definition:

    1. Start VS Code and open your project folder.
    2. Press F1 select and Remote-Containers: Add Development Container Configuration Files... from the command palette.
    3. Select the Docker in Docker definition.
  3. To use latest-and-greatest copy of this definition from the repository:

    1. Clone this repository.
    2. Copy the contents of containers/docker-in-docker/.devcontainer to the root of your project folder.
    3. Start VS Code and open your project folder.
  4. After following step 2 or 3, the contents of the .devcontainer folder in your project can be adapted to meet your needs.

  5. Finally, press F1 and run Remote-Containers: Reopen Folder in Container to start using the definition.


Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License. See LICENSE.

You can’t perform that action at this time.