Skip to content

Instantly share code, notes, and snippets.

@phucnguyen81
Created May 7, 2025 00:51
Show Gist options
  • Select an option

  • Save phucnguyen81/66e61659aec68bb63d270cb7cb3e8c99 to your computer and use it in GitHub Desktop.

Select an option

Save phucnguyen81/66e61659aec68bb63d270cb7cb3e8c99 to your computer and use it in GitHub Desktop.
Connect Docker CLI on Windows to Docker daemon inside a Linux VM via SSH

Connect Docker CLI on Windows to Docker daemon inside a Linux VM via SSH

Download the Docker CLI executable (docker.exe) from the official Docker static binaries repository: https://download.docker.com/win/static/stable/x86_64/

Option 1: SSH without config

Using Docker command with -H flag: docker -H ssh://user@vm-ip ps

Set environment variable to avoid specifying -H every time: On PowerShell: $env:DOCKER_HOST="ssh://user@vm-ip"

Option 2: SSH with config

For convenience, edit SSH config file (~/.ssh/config) to define the VM host with parameters: Host myvm HostName vm-ip User user IdentityFile C:\path\to\private_key

Then set DOCKER_HOST using the config name: On PowerShell: $env:DOCKER_HOST="ssh://myvm"

Then simply use Docker command as normal: docker ps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment