Skip to content

Use remote Docker Engine via SSH or using Docker context #540

Open

Description

@WojciechNagorski

Steps to reproduce the issue:

  1. Create the DockerClient that use connection via SSH
using Docker.DotNet;
DockerClient client = new DockerClientConfiguration(
    new Uri("ssh://[email protected]"))
     .CreateClient();

What actually happened?:

I've got an excetption:

Unhandled exception. System.Exception: Unknown URL scheme ssh
   at Docker.DotNet.DockerClient..ctor(DockerClientConfiguration configuration,
Version requestedApiVersion) in D:\work\Docker.DotNet\src\Docker.DotNet\DockerCl
ient.cs:line 135
   at Docker.DotNet.DockerClientConfiguration.CreateClient(Version requestedApiV
ersion) in D:\work\Docker.DotNet\src\Docker.DotNet\DockerClientConfiguration.cs:
line 54
   at Docker.DotNet.DockerClientConfiguration.CreateClient() in D:\work\Docker.D
otNet\src\Docker.DotNet\DockerClientConfiguration.cs:line 49
   at DockerTester.Program.Main(String[] args) in C:\Users\nagorski\RiderProject
s\DockerTester\DockerTester\Program.cs:line 21
   at DockerTester.Program.<Main>(String[] args)

What did you expect to happen?:

I should be able to use remote Docker via SSH. Currently Docker CLI has support for Docker context. I think I should be able to use Docker.DotNet API in the same way.

For Example, I can add Docker context using the following command:

docker context create --docker host=ssh://[email protected] --description="Remote engine" my-remote-engine

Then I can use the remote Docker engine using the --context parameter:

docker --context my-remote-engine images

More information:

Currently I can't use either Docker Engine via SSH or docker context.

Additional information:

Output of dotnet --info:

❯ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100-rc.1.21463.6
 Commit:    e627d556a1

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\

Host (useful for support):
  Version: 6.0.0-rc.1.21451.13
  Commit:  d7619cd4b1

.NET SDKs installed:
  2.1.520 [C:\Program Files\dotnet\sdk]
  3.1.300 [C:\Program Files\dotnet\sdk]
  5.0.204 [C:\Program Files\dotnet\sdk]
  5.0.401 [C:\Program Files\dotnet\sdk]
  6.0.100-rc.1.21463.6 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.1.21452.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.1.21451.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-rc.1.21451.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

What version of Docker.DotNet?:

latest

Activity

  1. behnam-basketasia commented on Nov 8, 2021

    @behnam-basketasia

    @galvesribeiro do you have plan to fix add this ability? connect to docker with ssh

  2. schmik commented on Nov 19, 2021

    @schmik

    @behnam-basketasia I assume PR are most welcome ;-)

  3. codingbott commented on Nov 6, 2024

    @codingbott

    There is already a fork TrapTech.Docker.DotNet.SSH which is providing the function you are asking for. Maybe that fork can merged into here. (https://github.com/TrapTech/Docker.DotNet)
    I personally would prefer that the ssh support is build into this lib here.

    My use case:
    I'm not exposing docker api on remote hosts for security reasons. I also don't install any docker stuff on my windows computer. This is the reason why I rely on the the SSH. I also use the test containers linked in a comment before.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions