Is it possible to use this package on MacOS with M1?
- Dominant language
- C#
- Stars
- 2.4k
- Forks
- 416
- PR merge metrics
- No merged PRs in 30d
Description
Apologies if this is my lack of brain power but after two days of trying to get this to work I thought I'd just check it's actually possible. I've had a search through the issues and there seem to be a few from people running on MacOS, but I'm at a loss as to how to get things to work.
Right now I have the following class:
```csharp
public class DockerSetup : IAsyncLifetime
{
private readonly DockerClient _dockerClient;
private string? _containerId;
private const string ContainerImageUri = "mcr.microsoft.com/azure-sql-edge";
public DockerSetup()
{
_dockerClient = new DockerClientConfiguration(DockerApiUri()).CreateClient();
}
public async Task InitializeAsync()
{
await PullImage();
await StartContainer();
}
private Uri DockerApiUri()
{
var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
if (isWindows)
{
return new Uri("npipe://./pipe/docker_engine");
}
var isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
var isMacOs = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
if (isLinux || isMacOs)
{
return new Uri("unix:/var/run/docker.sock");
}
throw new Exception(
"Was unable to determine what OS this is running on, does not appear to be Windows or Linux!?");
}
private async Task PullImage()
{
await _dockerClient.Images
.CreateImageAsync(new ImagesCreateParameters { FromImage = ContainerImageUri, Tag = "latest" },
new AuthConfig(),
new Progress());
}
private async Task StartContainer()
{
var response = await _dockerClient.Containers.CreateContainerAsync(new CreateContainerParameters
{
Image = ContainerImageUri, Env = new[] { "ACCEPT_EULA=y", "MSSQL_SA_PASSWORD=IntegrationTestingFTW!" }, HostConfig = new HostConfig { PortBindings = new Dictionary> { { "1433/tcp", new PortBinding[] { new PortBinding { HostPort = "14333" } } } } }
});
_containerId = response.ID;
await _dockerClient.Containers.StartContainerAsync(_containerId, null);
}
public async Task DisposeAsync()
{
if (_containerId != null)
{
await _dockerClient.Containers.KillContainerAsync(_containerId, new ContainerKillParameters());
}
}
}
```
But whenever I try to use it in a test I get an error `System.Net.Http.HttpRequestException: Connection failed`. Here is the info from `dotnet --info`
```
.NET SDK:
Version: 7.0.100-rc.2.22477.23
Commit: 0a5360315a
Runtime Environment:
OS Name: Mac OS X
OS Version: 12.6
OS Platform: Darwin
RID: osx.12-arm64
Base Path: /usr/local/share/dotnet/sdk/7.0.100-rc.2.22477.23/
Host:
Version: 7.0.0-rc.2.22472.3
Architecture: arm64
Commit: 550605cc93
.NET SDKs installed:
6.0.402 [/usr/local/share/dotnet/sdk]
7.0.100-rc.2.22477.23 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.0-rc.2.22476.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.0-rc.2.22472.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
```
And I'm running MacOS Monterey 12.6 with Docker 4.13.0.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.