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

Update Docker containers #22

Merged
merged 1 commit into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions containers/docker-in-docker-compose/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@
# Note: You can use any Debian/Ubuntu based image you want.
FROM debian:9

# Install git, process tools
RUN apt-get update && apt-get -y install git procps
# Copy settings file so Docker extension is installed inside the container
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json

# Configure apt
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils 2>&1

# Verify git, process tools installed
RUN apt-get -y install git procps

# Install Docker CE CLI
RUN apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release \
&& curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null \
&& curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT) \
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" \
&& apt-get update \
&& apt-get install -y docker-ce-cli
Expand All @@ -20,4 +28,5 @@ RUN apt-get install -y apt-transport-https ca-certificates curl gnupg-agent soft
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
ENV DEBIAN_FRONTEND=dialog

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"remote.extensionKind": {
"peterjausovec.vscode-docker": "workspace"
}
}
24 changes: 21 additions & 3 deletions containers/docker-in-docker-compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Summary

*Use Docker Compose to configure access to your local Docker install from inside a container.*
*Use Docker Compose to configure access to your local Docker install from inside a container. Installs Docker extension in the container along with needed CLIs.*

| Metadata | Value |
|----------|-------|
Expand All @@ -14,7 +14,9 @@

## Description

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](https://marketplace.visualstudio.com/items?itemName=PeterJausovec.vscode-docker) right from inside your dev container.
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](https://marketplace.visualstudio.com/items?itemName=PeterJausovec.vscode-docker) 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

Expand All @@ -37,7 +39,23 @@ You can adapt your own existing development container Docker Compose setup to su
- /var/run/docker.sock:/var/run/docker.sock
```

3. Press <kbd>F1</kbd> and run **Remote-Containers: Rebuild Container** so the changes take effect.
3. Add a container specific user settings file that forces the Docker extension to be installed inside the container instead of locally. From `.devcontainer/Dockerfile`:

```Dockerfile
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
```

From `.devcontainer/settings.vscode.json`:

```json
{
"remote.extensionKind": {
"peterjausovec.vscode-docker": "workspace"
}
}
```

4. Press <kbd>F1</kbd> and run **Remote-Containers: Rebuild Container** so the changes take effect.

That's it!

Expand Down
16 changes: 13 additions & 3 deletions containers/docker-in-docker/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@
# Note: You can use any Debian/Ubuntu based image you want.
FROM debian:9

# Install git, process tools
RUN apt-get update && apt-get -y install git procps
# Copy settings file so Docker extension is installed inside the container
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json

# Configure apt
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils 2>&1

# Verify git, process tools installed
RUN apt-get -y install git procps

# Install Docker CE CLI
RUN apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release \
&& curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null \
&& curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT) \
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" \
&& apt-get update \
&& apt-get install -y docker-ce-cli
Expand All @@ -21,4 +29,6 @@ RUN apt-get install -y apt-transport-https ca-certificates curl gnupg-agent soft
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
ENV DEBIAN_FRONTEND=dialog


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"remote.extensionKind": {
"peterjausovec.vscode-docker": "workspace"
}
}
24 changes: 21 additions & 3 deletions containers/docker-in-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Summary

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

| Metadata | Value |
|----------|-------|
Expand All @@ -14,7 +14,9 @@

## Description

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](https://marketplace.visualstudio.com/items?itemName=PeterJausovec.vscode-docker) right from inside your dev container.
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](https://marketplace.visualstudio.com/items?itemName=PeterJausovec.vscode-docker) 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

Expand All @@ -38,7 +40,23 @@ You can adapt your own existing development container Dockerfile to support this
"runArgs": ["-v","/var/run/docker.sock:/var/run/docker.sock"]
```

3. Press <kbd>F1</kbd> and run **Remote-Containers: Rebuild Container** so the changes take effect.
3. Add a container specific user settings file that forces the Docker extension to be installed inside the container instead of locally. From `.devcontainer/Dockerfile`:

```Dockerfile
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
```

From `.devcontainer/settings.vscode.json`:

```json
{
"remote.extensionKind": {
"peterjausovec.vscode-docker": "workspace"
}
}
```

4. Press <kbd>F1</kbd> and run **Remote-Containers: Rebuild Container** so the changes take effect.

That's it!

Expand Down
17 changes: 13 additions & 4 deletions containers/kubernetes-helm/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@
# You can use any Debian/Ubuntu based image as abase
FROM debian:9

# Install git, process tools
RUN apt-get update && apt-get -y install git procps
# Copy settings file so Docker extension is installed inside the container
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json

# Configure apt
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils 2>&1

# Verify git, process tools installed
RUN apt-get -y install git procps

# Install Docker CE CLI
RUN apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release \
&& curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null \
&& curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT) \
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" \
&& apt-get update \
&& apt-get install -y docker-ce-cli

# Install kubectl
RUN curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - 2>/dev/null \
RUN curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT) \
&& echo "deb https://apt.kubernetes.io/ kubernetes-$(lsb_release -cs) main" | tee -a /etc/apt/sources.list.d/kubernetes.list \
&& apt-get update \
&& apt-get install -y kubectl
Expand All @@ -37,3 +45,4 @@ RUN echo 'if [ "$SYNC_LOCALHOST_KUBECONFIG" == "true" ]; then \
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
ENV DEBIAN_FRONTEND=dialog
5 changes: 5 additions & 0 deletions containers/kubernetes-helm/.devcontainer/settings.vscode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"remote.extensionKind": {
"peterjausovec.vscode-docker": "workspace"
}
}
26 changes: 21 additions & 5 deletions containers/kubernetes-helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

## Description

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 a local or remote [Kubernetes](https://kubernetes.io/) cluster without affecting your dev container. This example illustrates how you can do this by using CLIs, the [Kubernetes extension](https://marketplace.visualstudio.com/items?itemName=ms-kubernetes-tools.vscode-kubernetes-tools), and the [Docker extension](https://marketplace.visualstudio.com/items?itemName=PeterJausovec.vscode-docker) right from inside your dev container.
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 a local or remote [Kubernetes](https://kubernetes.io/) cluster without affecting your dev container.

This definition builds up from the [docker-in-docker](../docker-in-docker) container definition to add Kubernetes and Helm support.
This example illustrates how you can do this by using CLIs ([kubectl](https://kubernetes.io/docs/reference/kubectl/overview/), [Helm](https://helm.sh), Docker), the [Kubernetes extension](https://marketplace.visualstudio.com/items?itemName=ms-kubernetes-tools.vscode-kubernetes-tools), and the [Docker extension](https://marketplace.visualstudio.com/items?itemName=PeterJausovec.vscode-docker) right from inside your dev container. This definition builds up from the [docker-in-docker](../docker-in-docker) container definition to add Kubernetes and Helm support. It installs the Docker and Kubernetes extensions inside the container so you can use its full feature set with your project.

The dev container includes the needed CLIs ([kubectl](https://kubernetes.io/docs/reference/kubectl/overview/), [Helm](https://helm.sh), Docker) and syncs your local Kubernetes config (`~/.kube/config` or `%USERPROFILE%\.kube\config`) into the container with the necessary modifications to allow it to interact with anything running on your local machine. This includes interacting with a Kubernetes cluster managed through Docker Desktop or a local Minikube install.
The dev container also syncs your local Kubernetes config (`~/.kube/config` or `%USERPROFILE%\.kube\config`) into the container with the necessary modifications to allow it to interact with anything running on your local machine whenever the container or a terminal window is started. This includes interacting with a Kubernetes cluster managed through Docker Desktop or a local Minikube install.

## How it works / adapting your existing dev container config

Expand Down Expand Up @@ -50,7 +50,7 @@ You can adapt your own existing development container Dockerfile to support this
"-v", "$HOME/.kube:/root/.kube-localhost"]
```

3. Finally, update `.bashrc` to automatically swap out localhost for host.docker.internal in a containr copy of the Kubernetes config. From `.devcontainer/Dockerfile`:
3. Update `.bashrc` to automatically swap out localhost for host.docker.internal in a containr copy of the Kubernetes config. From `.devcontainer/Dockerfile`:

```Dockerfile
RUN echo 'if [ "$SYNC_LOCALHOST_KUBECONFIG" == "true" ]; then \
Expand All @@ -60,7 +60,23 @@ You can adapt your own existing development container Dockerfile to support this
fi' >> $HOME/.bashrc
```

3. Press <kbd>F1</kbd> and run **Remote-Containers: Rebuild Container** so the changes take effect.
5. Add a container specific user settings file that forces the Docker extension to be installed inside the container instead of locally. From `.devcontainer/Dockerfile`:

```Dockerfile
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
```

From `.devcontainer/settings.vscode.json`:

```json
{
"remote.extensionKind": {
"peterjausovec.vscode-docker": "workspace"
}
}
```

6. Press <kbd>F1</kbd> and run **Remote-Containers: Rebuild Container** so the changes take effect.

That's it!

Expand Down