Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Unknown URL scheme unix' Exception when running with mono on Linux #322

Open
phildrip opened this issue Jun 26, 2018 · 6 comments
Open

Comments

@phildrip
Copy link

phildrip commented Jun 26, 2018

Output of dotnet --info:

 $ dotnet --info
.NET Command Line Tools (2.1.201)

Product Information:
 Version:            2.1.201
 Commit SHA-1 hash:  7932dc6179

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  16.04
 OS Platform: Linux
 RID:         ubuntu.16.04-x64
 Base Path:   /home/phil/.dotnet/sdk/2.1.201/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.7
  Build    : 2d61d0b043915bc948ebf98836fefe9ba942be11

What version of Docker.DotNet?:

3.125.2

Steps to reproduce the issue:

  1. Attempt to use the library to connect to the docker daemon on linux, building with mono (in a project targeting net471): var dockerClient = new DockerClientConfiguration("unix:///var/run/docker.sock").CreateClient();
  2. Exception will be thrown.

What actually happened?:
An Exception with the message "Unknown URL scheme unix" was thrown.

What did you expect to happen?:
The connection to the docker daemon was made successfully, just as if building and running a dotnet core netcoreapp2.0 project.

@jterry75
Copy link
Contributor

I don't know if net471. It might only be .NETCore that does because its cross plat. So I think this is by design actually.

@alastairs
Copy link

@jterry75 The Mono framework supports projects targeting net471 (amongst many other versions), so I would expect this to work on Unix even with a net4xx target.

@jterry75
Copy link
Contributor

I don't know that much about the Mono framework. Can you write a sample program that targets net4xx and tries to open a unix socket by uri? We aren't doing anything special here so my guess is that it will fail with the same error.

@alastairs
Copy link

I've added a repro project, with verification instructions to https://github.com/alastairs/docker.net-repro

This is the sample program in full:

using System;
using System.Threading.Tasks;
using Docker.DotNet;
using Docker.DotNet.Models;

namespace Repro
{
    class Program
    {
        static async Task Main(string[] args)
        {
            var client = new DockerClientConfiguration(new Uri("unix:///var/run/docker.sock")).CreateClient();
            await client.Images.ListImagesAsync(new ImagesListParameters
            {
                All = true
            });
        }
    }
}

The exception is thrown at line 12, and appears to be a direct result of this #if, which excludes support for unix URLs if the target framework is not .NET Standard 1.6 or 2.0.

@galvesribeiro
Copy link
Member

Yes... Mono support Unix sockets even on fullfx... I'm not sure why that #if is there...

I believe when that was wrote, mono didn't had support for it directly... Perhaps you could put a PR @alastairs with that change.

Mono isn't even listed here https://docs.microsoft.com/en-us/dotnet/standard/frameworks however, I know netstandard2.0 covers latest versions of Mono.

@jterry75 perhaps its time to change the targets and only target net45 or net46 and netstandard2.0 so Mono would be covered by later... What do you think?

In all cases, for production server apps, I would still recommend use .Net Core as @jterry75 recommended.

@galvesribeiro
Copy link
Member

Hummm... On a second thought, look at this: https://github.com/dotnet/standard/blob/master/docs/versions.md#net-standard-versions

Mono 4.6 is supported on all netstandard versions, except 2.0 which requires 5.4`...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants