diff --git a/containers/docker-in-docker-compose/.devcontainer/Dockerfile b/containers/docker-in-docker-compose/.devcontainer/Dockerfile index 6f21c21256..47956aa975 100644 --- a/containers/docker-in-docker-compose/.devcontainer/Dockerfile +++ b/containers/docker-in-docker-compose/.devcontainer/Dockerfile @@ -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 @@ -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 diff --git a/containers/docker-in-docker-compose/.devcontainer/settings.vscode.json b/containers/docker-in-docker-compose/.devcontainer/settings.vscode.json new file mode 100644 index 0000000000..360c5b2bf6 --- /dev/null +++ b/containers/docker-in-docker-compose/.devcontainer/settings.vscode.json @@ -0,0 +1,5 @@ +{ + "remote.extensionKind": { + "peterjausovec.vscode-docker": "workspace" + } +} \ No newline at end of file diff --git a/containers/docker-in-docker-compose/README.md b/containers/docker-in-docker-compose/README.md index 2f39bc6169..5493f10529 100644 --- a/containers/docker-in-docker-compose/README.md +++ b/containers/docker-in-docker-compose/README.md @@ -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 | |----------|-------| @@ -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 @@ -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 F1 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 F1 and run **Remote-Containers: Rebuild Container** so the changes take effect. That's it! diff --git a/containers/docker-in-docker/.devcontainer/Dockerfile b/containers/docker-in-docker/.devcontainer/Dockerfile index 20fe10a302..f435b1dee5 100644 --- a/containers/docker-in-docker/.devcontainer/Dockerfile +++ b/containers/docker-in-docker/.devcontainer/Dockerfile @@ -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 @@ -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 + diff --git a/containers/docker-in-docker/.devcontainer/settings.vscode.json b/containers/docker-in-docker/.devcontainer/settings.vscode.json new file mode 100644 index 0000000000..360c5b2bf6 --- /dev/null +++ b/containers/docker-in-docker/.devcontainer/settings.vscode.json @@ -0,0 +1,5 @@ +{ + "remote.extensionKind": { + "peterjausovec.vscode-docker": "workspace" + } +} \ No newline at end of file diff --git a/containers/docker-in-docker/README.md b/containers/docker-in-docker/README.md index 438ec59cd4..2ca1f5ff5b 100644 --- a/containers/docker-in-docker/README.md +++ b/containers/docker-in-docker/README.md @@ -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 | |----------|-------| @@ -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 @@ -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 F1 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 F1 and run **Remote-Containers: Rebuild Container** so the changes take effect. That's it! diff --git a/containers/kubernetes-helm/.devcontainer/Dockerfile b/containers/kubernetes-helm/.devcontainer/Dockerfile index c193e09aa6..c54021eac2 100644 --- a/containers/kubernetes-helm/.devcontainer/Dockerfile +++ b/containers/kubernetes-helm/.devcontainer/Dockerfile @@ -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 @@ -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 diff --git a/containers/kubernetes-helm/.devcontainer/settings.vscode.json b/containers/kubernetes-helm/.devcontainer/settings.vscode.json new file mode 100644 index 0000000000..360c5b2bf6 --- /dev/null +++ b/containers/kubernetes-helm/.devcontainer/settings.vscode.json @@ -0,0 +1,5 @@ +{ + "remote.extensionKind": { + "peterjausovec.vscode-docker": "workspace" + } +} \ No newline at end of file diff --git a/containers/kubernetes-helm/README.md b/containers/kubernetes-helm/README.md index e6f61e4163..e9bdb1f1a8 100644 --- a/containers/kubernetes-helm/README.md +++ b/containers/kubernetes-helm/README.md @@ -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 @@ -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 \ @@ -60,7 +60,23 @@ You can adapt your own existing development container Dockerfile to support this fi' >> $HOME/.bashrc ``` -3. Press F1 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 F1 and run **Remote-Containers: Rebuild Container** so the changes take effect. That's it!