How can I connect to my local Docker service using Docker.DotNet library in Linux environment (considering that I am using .Net Core 2.0)?
I think it is somehow related to /var/run/docker.sock
file, but I could not figure out how to achieve that.
How can I connect to my local Docker service using Docker.DotNet library in Linux environment (considering that I am using .Net Core 2.0)?
I think it is somehow related to /var/run/docker.sock
file, but I could not figure out how to achieve that.
This issue has been reported, and according to the discussion in here, the following should work on linux:
DockerClient client = new DockerClientConfiguration(new Uri("unix:///var/run/docker.sock"))
.CreateClient()
I created a kind of helpers class which provide the default local api uri depending on the underlying OS:
public static class Docker
{
static Docker()
{
DefaultLocalApiUri = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? new Uri("npipe://./pipe/docker_engine")
: new Uri("unix:/var/run/docker.sock");
}
public static Uri DefaultLocalApiUri { get; }
}