Using devcontainers in Apple macOS

Table of contents

Local Installation on a computer running macOS

To run devcontainers locally (on your own computer running macOS), you need to install and configure:

  • Docker Desktop;
  • VS Code; and
  • a number of VS Code extensions.

Install and configure Docker Desktop

Once you have installed Docker Desktop, start the application and ensure that it is running. You can check that it is running by looking for the Docker Desktop icon in the macOS Launchpad. You should not need to create a Docker account to use the application but it must be running to use devcontainers. It can be configured to start on boot if you wish. When running, a Docker icon displays at the top of your screen.

Click on the docker icon to see the list of devcontainers on your computer. You should see a list of devcontainers that you have previously run. If you have not run any devcontainers, this list will be empty. The devcontainers indicate whether they are running or not.

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 macOS

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

code .

Install VS Code extensions

The capabilities of VS Code can be augmented using VS Code extensions. If 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.

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

Running Devcontainers on macOS

  1. Open a Terminal in macOS
  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.

[!TIP] You can open macOS Explorer in this location by typing open . - note the dot again here

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 macOS should automatically restart the devcontainer and open the previous editor windows.