Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
docker-in-docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuxel committed Feb 6, 2019
1 parent 815095b commit 7ef4cf3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dockerFile": "dev-container.dockerfile",
"extensions": [
"peterjausovec.vscode-docker"
],
"runArgs": ["-v","/var/run/docker.sock:/var/run/docker.sock"]
}
23 changes: 23 additions & 0 deletions dev-containers/docker-in-docker-container/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Docker in Docker Container

This example has a dev container that actually contains the Docker CLI. This allows you to use the Docker extension and run docker commands from within a dev container that can still control, interact with, and deploy to your local OS Docker install!

While this will run out-of-box on macOS and Linux, there is an extra **step for Windows**.

## Windows Steps

1. Install "Docker Desktop for Windows" locally if you have not.

2. Right Click on Docker system tray icon and select "Settings"

3. Check **General > "Expose daemon on tcp://localhost:2375 without TLS"**

4. Wait for Docker to restart.

5. Open this folder in VS Code and modify the `runArgs` in `.vscode/devContainer.json` as follows:
```
"runArgs": ["-e","DOCKER_HOST=tcp://host.docker.internal:2375"]
```
> **Note:** Resolving [vscode-remote#669](https://github.com/Microsoft/vscode-remote/issues/669) will remove this step.
6. Run the **Remote: Reopen folder in Container"** command
20 changes: 20 additions & 0 deletions dev-containers/docker-in-docker-container/dev-container.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Note: You can use any Debian/Ubuntu based image you want.
FROM ubuntu:latest

# Install required tools
RUN apt-get update \
&& apt-get install -y git

# Install Docker CE
RUN apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common \
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
&& apt-get update \
&& apt-get install -y docker-ce-cli

# Clean up
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& apt-get autoclean -y \
&& rm -rf /var/lib/apt/lists/*

0 comments on commit 7ef4cf3

Please sign in to comment.