Use or extend the new Ubuntu-based default, large, multi-language universal container for GitHub Codespaces.
Metadata | Value |
---|---|
Contributors | The GitHub Codespaces team |
Categories | Services, GitHub |
Definition type | Dockerfile |
Published image | mcr.microsoft.com/vscode/devcontainers/universal:linux mcr.microsoft.com/vscode/devcontainers/universal:focal |
Published image architecture(s) | x86-64 |
Works in Codespaces | Yes |
Container host OS support | Linux, macOS, Windows |
Container OS | Ubuntu |
Languages, platforms | Python, Node.js, JavaScript, TypeScript, C++, Java, C#, F#, .NET Core, PHP, Go, Ruby, Conda |
See history for information on the contents of published images.
While language specific development containers can be useful, in some cases you may want to use more than one in a project without having to set them all up. In other cases you may be looking to create a general "sandbox" container you intend to use with multiple projects or repositories. The large container image generated here (mcr.microsoft.com/vscode/devcontainers/universal:linux
) includes a number of runtime versions for popular languages lke Python, Node, PHP, Java, Go, C++, Ruby, and .NET Core/C# - many of which are inherited from the Oryx build image it is based on.
If you use GitHub Codespaces, this is the "universal" image that is used by default if no custom Dockerfile or image is specified. If you like what you see but want to make a few additions or changes, you can use a custom Dockerfile to extend it and add whatever you need.
The container includes the zsh
(and Oh My Zsh!) and fish
shells that you can opt into using instead of the default bash
. It also includes nvm, rvm, rbenv, and SDKMAN! if you need to install a different version Node, Ruby, or Java tools than the container defaults. You can also set things up to access the container via SSH.
You can decide how often you want updates by referencing a semantic version of each image. However, note that only the most recent image is pre-cached in Codespaces. For example:
mcr.microsoft.com/vscode/devcontainers/universal:1-focal
mcr.microsoft.com/vscode/devcontainers/universal:1.3-focal
mcr.microsoft.com/vscode/devcontainers/universal:1.3.3-focal
See history for information on the contents of each version and here for a complete list of available tags.
This container also includes a running SSH server that you can use to access the contents if needed. To use it:
-
Create a codespace in GitHub Codespaces (this is the default image) or open this container in Remote - Containers.
-
If you created a codespace using a web browser in GitHub Codespaces, setup the VS Code extension and connect to it from your local VS Code.
-
When connected to the codespace, use a terminal in VS Code to set a password when connecting:
sudo passwd $(whoami)
-
Press F1 and select Forward a Port... and enter port
2222
. -
You're all set! You can connect using SSH as follows:
ssh -p 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null codespace@localhost
The
-o
arguments are not required, but will avoid errors about the "known host" signature changing when doing this from multiple codespaces. -
Enter the password you set in step 3.
That's it! Use similar arguments to those in step 5 when executing scp
or configuring SSHFS.
This dev container and its associated image includes the conda
package manager. Additional packages installed using Conda will be downloaded from Anaconda or another repository if you configure one. To reconfigure Conda in this container to access an alternative repository, please see information on configuring Conda channels here.
Access to the Anaconda repository is covered by the Anaconda Terms of Service, which may require some organizations to obtain a commercial license from Anaconda. However, when this dev container or its associated image is used with GitHub Codespaces or GitHub Actions, all users are permitted to use the Anaconda Repository through the service, including organizations normally required by Anaconda to obtain a paid license for commercial activities. Note that third-party packages may be licensed by their publishers in ways that impact your intellectual property, and are used at your own risk.
While the definition itself works unmodified, you can also directly reference pre-built versions of .devcontainer/Dockerfile
by using the image
property in .devcontainer/devcontainer.json
or updating the FROM
statement in your own Dockerfile
to:
mcr.microsoft.com/vscode/devcontainers/universal:1-linux
Alternatively, you can use the contents of the Dockerfile
to fully customize your container's contents or to build it for a container host architecture not supported by the image.
Given its size, we do not recommend extending this image. However, you can add it to a project or codespace as follows:
-
If this is your first time using a development container, please see getting started information on setting up Remote-Containers or creating a codespace using GitHub Codespaces.
-
To use the pre-built image:
- Start VS Code and open your project folder or connect to a codespace.
- Press F1 select and Add Development Container Configuration Files... command for Remote-Containers or Codespaces.
- Select this definition.
-
To build a custom version of the image instead (which can take upwards of 30 mins):
- Clone this repository locally.
- Start VS Code and open your project folder or connect to a codespace.
- Use your local operating system's file explorer to drag-and-drop the locally cloned copy of the
.devcontainer
folder for this definition into the VS Code file explorer for your opened project or codespace. - Update
.devcontainer/devcontainer.json
to reference"dockerfile": "base.Dockerfile"
.
-
After following step 2 or 3, the contents of the
.devcontainer
folder in your project can be adapted to meet your needs. -
Finally, press F1 and run Remote-Containers: Reopen Folder in Container or Codespaces: Rebuild Container to start using the definition.n.
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License. See LICENSE.