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

Commit 63cc884

Browse files
committed
Update Docker containers
Adds setting to ensure Docker is installed on the workspace side. Also gets rid of warnings about debconf and apt-key.
1 parent f30604b commit 63cc884

File tree

9 files changed

+116
-21
lines changed

9 files changed

+116
-21
lines changed

containers/docker-in-docker-compose/.devcontainer/Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66
# Note: You can use any Debian/Ubuntu based image you want.
77
FROM debian:9
88

9-
# Install git, process tools
10-
RUN apt-get update && apt-get -y install git procps
9+
# Copy settings file so Docker extension is installed inside the container
10+
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
11+
12+
# Configure apt
13+
ENV DEBIAN_FRONTEND=noninteractive
14+
RUN apt-get update \
15+
&& apt-get -y install --no-install-recommends apt-utils 2>&1
16+
17+
# Verify git, process tools installed
18+
RUN apt-get -y install git procps
1119

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"remote.extensionKind": {
3+
"peterjausovec.vscode-docker": "workspace"
4+
}
5+
}

containers/docker-in-docker-compose/README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Summary
44

5-
*Use Docker Compose to configure access to your local Docker install from inside a container.*
5+
*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.*
66

77
| Metadata | Value |
88
|----------|-------|
@@ -14,7 +14,9 @@
1414
1515
## Description
1616

17-
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.
17+
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.
18+
19+
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.
1820

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

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

40-
3. Press <kbd>F1</kbd> and run **Remote-Containers: Rebuild Container** so the changes take effect.
42+
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`:
43+
44+
```Dockerfile
45+
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
46+
```
47+
48+
From `.devcontainer/settings.vscode.json`:
49+
50+
```json
51+
{
52+
"remote.extensionKind": {
53+
"peterjausovec.vscode-docker": "workspace"
54+
}
55+
}
56+
```
57+
58+
4. Press <kbd>F1</kbd> and run **Remote-Containers: Rebuild Container** so the changes take effect.
4159

4260
That's it!
4361

containers/docker-in-docker/.devcontainer/Dockerfile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@
77
# Note: You can use any Debian/Ubuntu based image you want.
88
FROM debian:9
99

10-
# Install git, process tools
11-
RUN apt-get update && apt-get -y install git procps
10+
# Copy settings file so Docker extension is installed inside the container
11+
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
12+
13+
# Configure apt
14+
ENV DEBIAN_FRONTEND=noninteractive
15+
RUN apt-get update \
16+
&& apt-get -y install --no-install-recommends apt-utils 2>&1
17+
18+
# Verify git, process tools installed
19+
RUN apt-get -y install git procps
1220

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"remote.extensionKind": {
3+
"peterjausovec.vscode-docker": "workspace"
4+
}
5+
}

containers/docker-in-docker/README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Summary
44

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

77
| Metadata | Value |
88
|----------|-------|
@@ -14,7 +14,9 @@
1414
1515
## Description
1616

17-
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.
17+
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.
18+
19+
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.
1820

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

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

41-
3. Press <kbd>F1</kbd> and run **Remote-Containers: Rebuild Container** so the changes take effect.
43+
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`:
44+
45+
```Dockerfile
46+
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
47+
```
48+
49+
From `.devcontainer/settings.vscode.json`:
50+
51+
```json
52+
{
53+
"remote.extensionKind": {
54+
"peterjausovec.vscode-docker": "workspace"
55+
}
56+
}
57+
```
58+
59+
4. Press <kbd>F1</kbd> and run **Remote-Containers: Rebuild Container** so the changes take effect.
4260

4361
That's it!
4462

containers/kubernetes-helm/.devcontainer/Dockerfile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,26 @@
66
# You can use any Debian/Ubuntu based image as abase
77
FROM debian:9
88

9-
# Install git, process tools
10-
RUN apt-get update && apt-get -y install git procps
9+
# Copy settings file so Docker extension is installed inside the container
10+
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
11+
12+
# Configure apt
13+
ENV DEBIAN_FRONTEND=noninteractive
14+
RUN apt-get update \
15+
&& apt-get -y install --no-install-recommends apt-utils 2>&1
16+
17+
# Verify git, process tools installed
18+
RUN apt-get -y install git procps
1119

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

1927
# Install kubectl
20-
RUN curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - 2>/dev/null \
28+
RUN curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT) \
2129
&& echo "deb https://apt.kubernetes.io/ kubernetes-$(lsb_release -cs) main" | tee -a /etc/apt/sources.list.d/kubernetes.list \
2230
&& apt-get update \
2331
&& apt-get install -y kubectl
@@ -37,3 +45,4 @@ RUN echo 'if [ "$SYNC_LOCALHOST_KUBECONFIG" == "true" ]; then \
3745
RUN apt-get autoremove -y \
3846
&& apt-get clean -y \
3947
&& rm -rf /var/lib/apt/lists/*
48+
ENV DEBIAN_FRONTEND=dialog
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"remote.extensionKind": {
3+
"peterjausovec.vscode-docker": "workspace"
4+
}
5+
}

containers/kubernetes-helm/README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
## Description
1414

15-
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.
15+
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.
1616

17-
This definition builds up from the [docker-in-docker](../docker-in-docker) container definition to add Kubernetes and Helm support.
17+
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.
1818

19-
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.
19+
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.
2020

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

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

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

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

63-
3. Press <kbd>F1</kbd> and run **Remote-Containers: Rebuild Container** so the changes take effect.
63+
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`:
64+
65+
```Dockerfile
66+
COPY settings.vscode.json /root/.vscode-remote/data/Machine/settings.json
67+
```
68+
69+
From `.devcontainer/settings.vscode.json`:
70+
71+
```json
72+
{
73+
"remote.extensionKind": {
74+
"peterjausovec.vscode-docker": "workspace"
75+
}
76+
}
77+
```
78+
79+
6. Press <kbd>F1</kbd> and run **Remote-Containers: Rebuild Container** so the changes take effect.
6480

6581
That's it!
6682

0 commit comments

Comments
 (0)