User Guide

  • 2022.2
  • 04/11/2022
  • Public Content

Developing a Visual Studio Code Project in a Docker Container

Using Visual Studio Code* with Intel® oneAPI Toolkits
The Intel® oneAPI Toolkits support these compilers:
  • Intel® oneAPI DPC++ Compiler
  • Intel® Fortran Compiler
  • Intel® C++ Compiler
Containers allow you to set up and configure environments for building, running and profiling oneAPI applications and distribute them using images:
  • You can install an image containing an environment pre-configured with all the tools you need, then develop within that environment.
  • You can save an environment and use the image to move that environment to another machine without additional setup.
  • You can prepare containers with different sets of languages and runtimes, analysis tools, or other tools, as needed.

Configure the Container

In order to debug inside of the container, you must enable debugging flags and configure the Intel oneAPI development environment variables within the container. This can be done by editing the
Debugging is only available for CPU applications. Debugging Intel oneAPI GPU applications in VS Code is not supported at this time.
  1. An extension is required to debug Intel oneAPI projects inside of a container. The Microsoft VS Code C/C++ Extension is required to configure the GDB debugger. This can installed automatically by adding it to the container configuration file. Edit the “extensions” line in
    // Add the IDs of extensions you want installed when the container is created. "extensions": ["ms-VS Code.cpptools"],
    The Intel extension is not POR and it is not available in the Marketplace.
  2. If you will be using a ptrace-based debugger for programming languages such as C++, Go, and Rust, you will need to enable debugging within the container. Uncomment the “runArgs” line in
    // Uncomment when using a ptrace-based debugger like C++, Go, and Rust "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
  3. In order to apply these changes to the container, it must be rebuilt. Open the Command Palette and run
    Remote-Containers: Rebuild Container
  4. The container will be rebuilt and show that the extensions have been installed.

Build a Sample Project

To build the project, follow the instructions in Note that when you open a Terminal in VS Code (
) while connected to a container, it opens a login terminal inside of the container.
Before working with oneAPI samples, it is recommended that you install the VS Code “Sample Browser for Intel oneAPI Toolkits” extension. It can be found in the VS Code extensions marketplace by typing “oneapi” into the marketplace search bar.
After the extension is installed, browse oneAPI samples using VS Code:
  1. Click on the oneAPI button on the left navigation to view samples. If you do not have the extension installed, search the Extensions Marketplace for “Sample Browser for Intel oneAPI Toolkits”.
  2. A list of available samples will open in the left navigation.
  3. To view the readme for the sample, click the image9 next to the sample. If you choose to build and run the sample, the readme will also be downloaded with the sample.
  4. To build and run a sample, click the foldericon to the right of the sample name.
  5. Create a new folder for the sample. The sample will load in a new window:
  6. Click to view instructions for the sample.
Not all oneAPI sample projects use CMake. The file for each sample specifies how to build the sample. We recommend that you check out the CMake extension for VS Code that is maintained by Microsoft.

Try Debugging (CPU and GPU Only) (Preview)

Intel® Distribution for GDB* does not currently support VS Code. You can use upstream gdb to debug.
This section assumes that you can build your sample and have installed the Microsoft VS Code C/C++ Extension. The C/C++ extension is required to configure the oneAPI C/C++ debugger.
The Intel® oneAPI Base Toolkit includes a special version of GNU* GDB (
) designed to support oneAPI C/C++ applications. To debug your DPC++ application using this special debugger, you will need to make changes to the .vscode/launch.json configuration file.
  1. Go to
    Open Configurations
    , and open the
    configuration settings.
If you are prompted to select a debug environment, choose
  1. Copy the code shown below into your launch.json file, and replace the
    property’s value with the path to your project’s executable (that is, the application that you are going to debug).
If VS Code doesn’t recognize the application name, you may have to insert the full path and file name into the
  1. Add
    to your launch.json configuration’s
application should have been added to your path when you ran to configure the oneAPI development environment, prior to starting VS Code. If you prefer, you can specify the full path and filename to the
application in your launch.json file.
  1. In some configurations, GDB may not be compatible with VS Code. If this happens, add the environment variable to disable `gdb-oneapi` support for GPU autolaunch. This can either be done in the environment prior to launching VS Code, or within the launch.json:
    { "version":"0.2.0", "configurations":[ { "name":"(gdb) Launch", "type":"cppdbg", "request":"launch", "program":"${workspaceFolder}/build/array-transform", "args":[ "cpu" ], "stopAtEntry":false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole":false, "MIMode":"gdb", "miDebuggerPath":"gdb-oneapi", "setupCommands":[ { "description":"Enable pretty-printing for gdb", "text":"-enable-pretty-printing", "ignoreFailures":true }, { "description": "Disable target async", "text": "set target-async off", "ignoreFailures": true } ] } ] }
  2. Bring up the debug view by selecting the
    icon in the
    Activity Bar
    . You can also use the keyboard shortcut (
  3. Start the run and debug session by clicking the green
    icon, or go to
    Start Debugging

Disconnect from the Container

You can close the VS Code connection to the container by selecting
File > Close Remote Connection
from the VS Code menu. Alternatively, click the colored
Dev Container
notification in the lower-left corner of the VS Code window and select
Close Remote Connection
from the list of

Product and Performance Information


Performance varies by use, configuration and other factors. Learn more at