Browse Source

DockerRunner: podman workaround: create volume host dir when it doesn't exist. (#1062)

pull/1119/head
Tom Deseyn 5 years ago
committed by GitHub
parent
commit
8310ecb63f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      src/Microsoft.Tye.Core/ContainerEngine.cs
  2. 9
      src/Microsoft.Tye.Hosting/DockerRunner.cs

1
src/Microsoft.Tye.Core/ContainerEngine.cs

@ -31,6 +31,7 @@ namespace Microsoft.Tye
public string AspNetUrlsHost => _aspnetUrlsHost;
public string? ContainerHost => _containerHost;
public bool IsPodman => _isPodman;
public Task<int> ExecuteAsync(
string args,

9
src/Microsoft.Tye.Hosting/DockerRunner.cs

@ -285,6 +285,15 @@ namespace Microsoft.Tye.Hosting
if (volumeMapping.Source != null)
{
var sourcePath = Path.GetFullPath(Path.Combine(application.ContextDirectory, volumeMapping.Source));
if (application.ContainerEngine.IsPodman)
{
// unlike docker, podman doesn't create the host directory when it doesn't exist.
// https://github.com/containers/podman/issues/10471
if (!File.Exists(sourcePath) && !Directory.Exists(sourcePath))
{
Directory.CreateDirectory(sourcePath);
}
}
volumes += $"-v \"{sourcePath}:{volumeMapping.Target}:{(volumeMapping.ReadOnly ? "ro," : "")}z\" ";
}
else if (volumeMapping.Name != null)

Loading…
Cancel
Save