The following is a quick reference for using Docker along with WSL2 directly (without Docker for Desktop)
Common Commands
# Create new image from Dockerfile
docker build -t cpptest/ubuntu cpptest-ubuntu
# Create new container
docker run --name cpptest -it cpptest/ubuntu
# If running docker container from root
Using VSCode with WSL2 Docker
Install Extensions
Docker (Microsoft)
Remote – WSL (Microsoft)
Open WSL Window
‘New WSL Window’ or click lower-left-corner
Ensure that it indicates “WSL: Ubuntu’ in lower-left corner
From ‘Docker’ tab
Start target container if not already started
Run command ‘Remote Containers – Attach to Running Container’ and select the desired container
From File Tab
use ‘Add Folder to Workspace’ to access one or more folders
use ‘Save Workspace as…’ to save the current workspace. (this workspace will be available via recently used in VSCode, so name descriptively)
Google Test within Ubuntu 20.04 Docker Container
apt-get update
apt-get -y install --no-install-recommends libgmock-dev
basic examples: https://github.com/echozulucode/cpp-challenges