6.6 KiB
Development Container Scripts
This folder contains a set of scripts that can be referenced by Dockerfiles in development container "definitions" that are found under the containers
directory. You are also free to use them in your own dev container configurations.
Scripts
Script names end in the Linux distribution "tree" they support. The majority are for Ubuntu/Debian.
- Debian or Ubuntu:
-debian
- CentOS, RHEL:
-redhat
(when theyum
package manager is available) - Alpine Linux:
-alpine
Some scripts have special installation instructions (like desktop-lite-debian.sh
). Consult the following documents for more information (in order of the script name):
Document | Script |
---|---|
Azure CLI Install Script | azcli-debian.sh |
Common Script | common-debian.sh common-alpine.sh common-redhat.sh |
Desktop (Lightweight) Install Script | desktop-lite-debian.sh |
Docker-from-Docker Install Script | docker-debian.sh docker-redhat.sh |
Git Build/Install from Source Script | git-from-src-debian.sh |
Git LFS Install Script | git-lfs-debian.sh |
GitHub CLI Install Script | github-debian.sh |
Go (golang) Install Script | go-debian.sh |
Gradle Install Script | gradle-debian.sh |
Java Install Script | java-debian.sh |
Kubectl and Helm Install Script | kubectl-helm-debian.sh |
Maven Install Script | maven-debian.sh |
Node.js Install Script | node-debian.sh |
PowerShell Install Script | powershell-debian.sh |
Python Install Script | python-debian.sh |
Ruby Install Script | ruby-debian.sh |
Rust (rustlang) Install Script | rust-debian.sh |
SSH Server Install Script | sshd-debian.sh |
Terraform CLI Install Script | terraform-debian.sh |
Using a script
See the documentation above for specific instructions on individual scripts. This section will outline some general tips for alternate ways to reference the scripts in your Dockerfile.
Copying the script to .devcontainer/library-scripts
The easiest way to use a script is to simply copy it into a .devcontainers/library-scripts
folder. From here you can then use the script as follows in your Dockerfile
:
Debian/Ubuntu
COPY library-scripts/*.sh /tmp/library-scripts/
RUN bash /tmp/library-scripts/common-debian.sh
Generally it's also good to clean up after running a script in the same RUN
statement to keep the "layer" small.
COPY library-scripts/*.sh /tmp/library-scripts/
RUN bash /tmp/library-scripts/common-debian.sh
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
Alpine
COPY library-scripts/*.sh /tmp/library-scripts/
RUN ash /tmp/library-scripts/common-alpine.sh \
&& rm -rf /tmp/library-scripts
CentOS/RedHat/Oracle Linux
COPY library-scripts/*.sh /tmp/library-scripts/
RUN bash /tmp/library-scripts/common-redhat.sh \
&& yum clean all && rm -rf /tmp/library-scripts
Note that the CI process for this repository will automatically keep scripts in the .devcontainers/library-scripts
folder up to date for each definition in the containers
folder.
Downloading the script with curl / wget instead
If you prefer, you can download the script using curl
or wget
and execute it instead. This can convenient to do with your own Dockerfile
, but is generally avoided for definitions in this repository. To avoid unexpected issues, you should reference a release specific version of the script, rather than using master. For example:
RUN bash -c "$(curl -fsSL "https://raw.githubusercontent.com/microsoft/vscode-dev-containers/v0.131.0/script-library/common-debian.sh")" \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
Or if you're not sure if curl
is installed:
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends curl ca-certificates \
&& bash -c "$(curl -fsSL "https://raw.githubusercontent.com/microsoft/vscode-dev-containers/v0.131.0/script-library/common-debian.sh")" \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
As before, the last line is technically optional, but minimizes the size of the layer by removing temporary contents.
You can also use wget
:
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends wget ca-certificates \
&& bash -c "$(wget -qO- "https://raw.githubusercontent.com/microsoft/vscode-dev-containers/v0.131.0/script-library/common-debian.sh")" \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
Arguments
Some scripts include arguments that you can allow developers to set by using ARG
in your Dockerfile
.
Using arguments with scripts from the .devcontainers/library-scripts folder
In this case, you can simply pass in the arguments to the script.
# Options for script
ARG INSTALL_ZSH="true"
COPY library-scripts/*.sh /tmp/library-scripts/
RUN /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "vscode" "1000" "1000" "true" \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
Using arguments when downloading with curl
The trick here is to use the double-dashes (--
) after the bash -c
command and then listing the arguments.
# Options for script
ARG INSTALL_ZSH="true"
# Download script and run it with the option above
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends curl ca-certificates \
&& bash -c "$(curl -fsSL "https://raw.githubusercontent.com/microsoft/vscode-dev-containers/v0.131.0/script-library/common-debian.sh")" -- "${INSTALL_ZSH}" "vscode" "1000" "1000" "true" \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
Testing
The test
sub-folder includes Debian, Alpine, and RedHat based dev containers that can be used to test the scripts.
Contributing
See CONTRIBUTING.md for details on contributing definitions to this repository.
License
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License. See LICENSE