Skip to content

Instantly share code, notes, and snippets.

@ai2ys
Last active April 1, 2022 08:42
Show Gist options
  • Save ai2ys/27cb6de3ef6b80b345c7871ce90ed849 to your computer and use it in GitHub Desktop.
Save ai2ys/27cb6de3ef6b80b345c7871ce90ed849 to your computer and use it in GitHub Desktop.
Create Docker Context for Remote Machine (Access via SSH)

Docker Context

Create a Docker context for remote Machine (access via SSH).

Create Docker context

# specifiy remote user, remote IP address, context name, and the description
remote_user=<user name>
remote_ip_address=<ip address of remote system>
context_name=<name for the context>
context_description="<some description>"

# creating the context
docker context create \
  ${context_name} \
  --docker host=ssh://${remote_user}@${remote_ip_address} \
  --description ${context_description}

Switch Docker context

# list contexts
docker context list

# switch context
docker context use <context name>

Set up SSH Tunneling (Windows)

Assuming an SSH key has already been created, following the instruction from: https://code.visualstudio.com/docs/containers/ssh#_set-up-ssh-tunneling

Windows

  • Open PowerShell as administrator
    Set-Service ssh-agent -StartupType "Automatic"
    Start-Service ssh-agent
  • Open a non-administrator CMD window
    ssh-add .ssh/<private key used for ssh to remote>
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment