IMPORTANT NOTE: We're starting to migrate contents of this repo to the devcontainers org, as part of the work on the open dev container specification.
We'll now be publishing the cpp image from devcontainers/images/src/cpp.
For more details, you can review the announcement issue.
Develop C++ applications on Linux. Includes Debian C++ build tools.
| Metadata | Value |
|---|---|
| Contributors | The VS Code Team |
| Categories | Core, Languages |
| Definition type | Dockerfile |
| Published images | mcr.microsoft.com/vscode/devcontainers/cpp |
| Available image variants | debian-11, debian-10, ubuntu-22.04, ubuntu-20.04, ubuntu-18.04 (full list) |
| Published image architecture(s) | x86-64, aarch64/arm64 for debian-11, ubuntu-22.04, and ubuntu-18.04 variants |
| Works in Codespaces | Yes |
| Container host OS support | Linux, macOS, Windows |
| Container OS | Debian, Ubuntu |
| Languages, platforms | C++ |
See history for information on the contents of published images.
While the definition itself works unmodified, you can select the version of Debian or Ubuntu the container uses by updating the VARIANT arg in the included devcontainer.json (and rebuilding if you've already created the container).
"args": { "VARIANT": "debian-11" }You can also directly reference pre-built versions of .devcontainer/base.Dockerfile by using the image property in .devcontainer/devcontainer.json or updating the FROM statement in your own Dockerfile to one of the following. An example Dockerfile is included in this repository.
mcr.microsoft.com/vscode/devcontainers/cpp(latest Debian GA)mcr.microsoft.com/vscode/devcontainers/cpp:debian(latest Debian GA)mcr.microsoft.com/vscode/devcontainers/cpp:debian-11(orbullseye)mcr.microsoft.com/vscode/devcontainers/cpp:debian-10(orbuster)mcr.microsoft.com/vscode/devcontainers/cpp:ubuntu(latest Ubuntu LTS)mcr.microsoft.com/vscode/devcontainers/cpp:ubuntu-22.04(orjammy)mcr.microsoft.com/vscode/devcontainers/cpp:ubuntu-20.04(orfocal)mcr.microsoft.com/vscode/devcontainers/cpp:ubuntu-18.04(orbionic)
You can decide how often you want updates by referencing a semantic version of each image. For example:
mcr.microsoft.com/vscode/devcontainers/cpp:0-bullseyemcr.microsoft.com/vscode/devcontainers/cpp:0.204-bullseyemcr.microsoft.com/vscode/devcontainers/cpp:0.204.0-bullseye
However, we only do security patching on the latest non-breaking, in support versions of images (e.g. 0-debian-11). You may want to run apt-get update && apt-get upgrade in your Dockerfile if you lock to a more specific version to at least pick up OS security updates.
See history for information on the contents of each version and here for a complete list of available tags.
Alternatively, you can use the contents of base.Dockerfile to fully customize your container's contents or to build it for a container host architecture not supported by the image.
Beyond git, this image / Dockerfile includes zsh, Oh My Zsh!, a non-root vscode user with sudo access, a set of common dependencies for development, and Vcpkg a cross-platform package manager for C++.
This dev container and its associated image includes a clone of the Vcpkg repo for library packages, and a bootstrapped instance of the Vcpkg-tool itself.
The minimum version of cmake required to install packages is higher than the version available in the main package repositories for Debian (<=11) and Ubuntu (<=21.10). Vcpkg will download a compatible version of cmake for its own use if that is the case (on x86_64 architectures), however you can opt to reinstall a different version of cmake globally by adding "REINSTALL_CMAKE_VERSION_FROM_SOURCE: "<VERSION>" to build args in .devcontainer/devcontainer.json. This will install cmake from its github releases. For example:
"args": {
"VARIANT": "debian-11",
"REINSTALL_CMAKE_VERSION_FROM_SOURCE": "3.21.5"
}Most additional library packages installed using Vcpkg will be downloaded from their official distribution locations. To configure Vcpkg in this container to access an alternate registry, more information can be found here: Registries: Bring your own libraries to vcpkg.
To update the available library packages, pull the latest from the git repository using the following command in the terminal:
cd "${VCPKG_ROOT}"
git pull --ff-onlyNote: Please review the Vcpkg license details to better understand its own license and additional license information pertaining to library packages and supported ports.
-
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. You may also need to select Show All Definitions... for it to appear.
-
To build a custom version of the image instead:
- 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
.devcontainerfolder for this definition into the VS Code file explorer for your opened project or codespace. - Update
.devcontainer/devcontainer.jsonto reference"dockerfile": "base.Dockerfile".
-
After following step 2 or 3, the contents of the
.devcontainerfolder 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.
This definition includes some test code that will help you verify it is working as expected on your system. Follow these steps:
- If this is your first time using a development container, please follow the getting started steps to set up your machine.
- Clone this repository.
- Start VS Code, press F1, and select Remote-Containers: Open Folder in Container...
- Select the
containers/cppfolder. - After the folder has opened in the container, press F5 to start the project.
- You should see "Hello, Remote World!" in the a terminal window after the program finishes executing.
- From here, you can add breakpoints or edit the contents of the
test-projectfolder to do further testing.
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License. See LICENSE.