This guide provides step-by-step instructions for setting up and using dev containers within the SDF Trusted Research Environment (TRE).
For users who want the fastest setup with automatic updates:
# 1. Pull the devcontainer image
ces-pull a a ghcr.io/smartdatafoundry/devcontainer:latest
# 2. Extract the setup scripts
podman run --rm -v $HOME:$HOME -w $HOME \
ghcr.io/smartdatafoundry/devcontainer:latest \
cp -r /opt/devcontainerctl $HOME/devcontainerctl
# 3. Run the one-time setup
cd $HOME/devcontainerctl
./setup.sh
# 4. Start your devcontainer
devcontainerctl startSee the "Using the Setup Scripts" section below for details.
For users who prefer manual control or are setting this up for the first time:
- Pull the devcontainer image
- Extract and install the Dev Containers extension
- Create your project directory
- Add project config file
.devcontainer/devcontainer.json - Open the project in VS Code
- Open in Container
- Option A: Click "Reopen in Container" when prompted by VS Code
- Option B: Open Command Palette (
Ctrl+Shift+P) and run "Dev Containers: Reopen in Container"
- Wait for container to start
- Do your work
See the sections below for detailed instructions.
The devcontainer includes scripts that automate deployment and management in the TRE environment.
After extracting the scripts (see Quick Start above), run the setup script:
cd $HOME/devcontainerctl
./setup.shThis script will:
- Create
~/bindirectory if it doesn't exist - Create a symlink to
devcontainerctlin~/bin - Add
~/binto your PATH (in~/.bashrc) - Configure a daily cron job (8:00 AM) to sync your image with latest version
After running the setup, either restart your terminal or run:
source ~/.bashrcOnce setup is complete, you can use the devcontainerctl command:
# Start your devcontainer (pulls latest matching image if needed)
devcontainerctl start
# Check status
devcontainerctl status
# Stop the container
devcontainerctl stop
# Restart the container
devcontainerctl restart
# Update to latest image and restart
devcontainerctl update
# Remove the container completely
devcontainerctl removeThe setup provides several automatic features:
-
Daily Updates: A cron job runs at 8:00 AM daily to sync your container image with the latest version matching your VS Code installation (using
devcontainerctl sync) -
VS Code Tag Alignment: The
devcontainerctl updatecommand automatically detects your installed VS Code version and starts the matching container image tag (e.g.,vscode-7d842fb) -
Automatic Mounting: Your home directory and
/safe_dataare automatically mounted when the container starts -
Proxy Configuration: HTTP proxy settings are inherited from your environment automatically
Verify you have access to ces-pull and Podman within your TRE workspace.
which ces-pull
# Should respond with the path to the command
# e.g. /usr/local/bin/ces-pull
which podman
# Should respond with the path to the command
# e.g. /usr/bin/podmanBefore using dev containers in the SDF Trusted Research Environment, you need to obtain the container image and manually install the Dev Containers extension in VS Code:
Pull the latest devcontainer image using the CES (Container Execution Service):
ces-pull a a ghcr.io/smartdatafoundry/devcontainer:latestThe Dev Containers extension VSIX is baked into the image for offline / restricted environments. Extract it:
podman run --rm \
-v $PWD:$PWD \
-w $PWD \
ghcr.io/smartdatafoundry/devcontainer:latest \
cp /opt/vscode-init/ms-vscode-remote.remote-containers.vsix .code --install-extension ms-vscode-remote.remote-containers.vsix- Open VS Code in your TRE environment
- Go to the Extensions tab
- Click on the 3-dot menu (⋯) in the Extensions panel
- Select "Install from VSIX..."
- Choose the
ms-vscode-remote.remote-containers.vsixfile you extracted
Add to your VS Code settings.json to configure Podman as the container runtime:
- Open VS Code
- Press
Ctrl+,to open Settings - Click the "Open Settings (JSON)" icon in the top-right corner
- Add the following configuration:
{
"dev.containers.dockerPath": "podman"
}You now have the container image available and VS Code setup to be able to use it.
Whenever you want to use the devcontainer for a project, you will need to create a configuration file. This is a one-time setup per project.
Create a .devcontainer/devcontainer.json file in your project root:
{
"name": "Development Container",
"image": "ghcr.io/smartdatafoundry/devcontainer:latest",
"mounts": [
"source=/safe_data,target=/safe_data,type=bind,consistency=cached",
"type=tmpfs,target=/tmp"
],
"runArgs": [
"--userns=host",
"-e http_proxy",
"-e https_proxy"
],
"remoteUser": "root"
}After creating this file you can reopen the project in VS Code using the Dev Containers extension.
-
mounts:- Binds the
/safe_datadirectory for access to project data - Creates a temporary filesystem for
/tmpfor TRE compatibility
- Binds the
-
runArgs:--userns=host: Uses the host user namespace for TRE compatibility-e http_proxyand-e https_proxy: Essential forpipand network calls to work within the TRE. These inherit proxy credentials from your TRE environment
-
remoteUser: Set torootfor TRE compatibility
When you create the devcontainer configuration:
- VS Code will prompt you to "Reopen in Container"
- Docker/Podman fires up the container and connects VS Code to it
- Your project directory is automatically mounted into the container
- Any changes made inside the container are preserved in your project files outside the container
- This avoids the "chicken and egg" problem of having source code baked into containers
This approach leverages container technology directly while maintaining the ability to modify and iterate on your code seamlessly.
The container ships with VS Code Server pre-installed. To ensure reproducibility or to match an existing TRE host version, specify the commit hash:
- Check your TRE VS Code version via Help > About
- The VS Code commit value is declared in the
Dockerfileand can be overridden via workflow inputs.
If you can't see "Dev Containers" in the VS Code command palette:
- Ensure you've followed the manual extension installation steps above
- Restart VS Code after installing the extension
- Check that the extension is enabled in the Extensions panel
- If you get Docker-related errors, ensure VS Code is configured to use podman:
"dev.containers.dockerPath": "podman" - If you get "Error: reading blob" or "500 Internal Server Error" when pulling images:
- Try using a different TRE workspace
- Contact TRE support if the issue persists
- Some workspaces may have image access restrictions
If you experience network-related delays:
- Ensure your proxy settings are correctly configured in the
runArgs(http_proxy and https_proxy are essential) - File system responsiveness may vary depending on TRE network conditions
If devcontainerctl command is not found:
- Ensure you've run the setup script:
./setup.sh - Check that
~/binis in your PATH:echo $PATH - Try restarting your terminal or running:
source ~/.bashrc
If cron job is not running:
- Verify it's configured:
crontab -l(should show:0 8 * * * $HOME/bin/devcontainerctl sync) - Check cron logs for errors
- Manually test the sync command:
devcontainerctl sync
For any other issues:
- Check the troubleshooting section above
- Contact SDF TRE support for workspace or network-related problems
- Report container-specific issues on our repo's GitHub Issues