Using devcontainers in Linux

Table of contents

Local Installation on a computer running Linux

To run devcontainers on a computer running Linux, you need to install and configure:

  • Docker;
  • VS Code; and
  • VS Code extensions

Install and configure Docker

The official Docker installation guide for Linux here.

A guide to getting started with Docker is a useful place to start to confirm the installation details.

You should not need to create a Docker account to use the application but the application must be running to use devcontainers. It can be configured to start on boot if you wish.

In Docker Desktop, go to Settings (the cog wheel in top right corner) / General and ensure that SBOM indexing and enable background SBOM indexing are both turned OFF. You may need to scroll down to find those settings. Also, ensure that under Settings / Features in Development all Beta and Experimental features are turned OFF. These settings can otherwise adversely impact performance on computers with constrained capacity.

Install VS Code for your version of Linux

Several Linux packages are supported by Visual Studio. Download and install the appropriate package VS Code for Linux using the package manager associated with your version of Linux.

Once VS Code for macOS is installed, try starting VS Code:

code .

The VS Code version can be checked with:

code --version

Install VS Code extensions

The capabilities of VS Code can be augmented using VS Code extensions.

Once VS Code is running successfully then you need to install the VS Code Dev Containers extension, which lets you run Visual Studio Code inside a Docker container. Install it by clicking here and then clicking the Install the Dev Containers extension button. Once complete, review the instructions here to test the installation.

This extension will also support running the devcontainer remotely on a Linux server.

If this is successful then congratulations! Your installation has been successful. You are now ready to run our devcontainers on your Linux computer.

Running devcontainers on Linux

  1. Open a Shell in Linux
  2. Clone a devcontainer repository to your local drive. For instance:
git clone https://github.com/McKibbin-Software-Group/gcubed-2R.git
  1. Change to the repository folder
cd gcubed-2R
  1. Start VS Code
code .

[!NOTE] Requires the ‘dot’ / ‘full stop’ after code - this instructs VS Code to open the current folder.

All going well, VS Code should open and display all the files & directories in that folder.

[!NOTE] The devcontainer has not started yet. You can just edit the files in that clone of the repo, but none of the development environment is running and you can’t access the G-Cubed tools. VS Code may at this point offer to reopen as a devcontainer (select that) or you may need to manually open the container.

You can manually start the devcontainer by pressing COMMAND+SHIFT+P and typing reopen. You should see a search window open and the option Dev Containers: Reopen in Container should appear at or near the top of the list. Select that option.

You can finish the session and shut down the container by simply closing the VS Code window. You can restart your session by re-opening a Terminal, changing to the repository folder, and starting VS Code code .

You may also need to reopen the devcontainer from within VS Code.

[!TIP] By default VS Code remembers where you left off and will restart in the same location. Simply starting VS Code from within Linux should automatically restart the devcontainer and open the previous editor windows.

Troubleshooting

  • Permissions Issues: Ensure your user is part of the docker group to avoid permission issues with Docker.
sudo usermod -aG docker $USER
newgrp docker
  • Container Build Issues: Check the output of the build process in the VS Code terminal for any errors.