Skip to content

Commit aa3573c

Browse files
authored
Merge pull request #296 from neuroglia-io/docker-runtime-fix
Fixed the DockerRuntime to only pull image with specific tag instead of all available tags
2 parents 974e2e4 + 807df21 commit aa3573c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/runtime/Synapse.Runtime.Docker/Services/DockerRuntime.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using Synapse.Infrastructure.Services;
2626
using Synapse.Runtime.Docker;
2727
using Synapse.Runtime.Docker.Configuration;
28+
using System.Reactive.Linq;
2829

2930
namespace Synapse.Runtime.Services
3031
{
@@ -145,9 +146,13 @@ public override async Task<IWorkflowProcess> CreateProcessAsync(V1Workflow workf
145146
/// <returns>A new awaitable <see cref="Task"/></returns>
146147
protected virtual async Task PullWorkerImageAsync(CancellationToken cancellationToken)
147148
{
149+
var image = this.Options.Runtime.Container.Image;
150+
var tagIndex = image.IndexOf(':');
151+
var tag = "latest";
152+
if (tagIndex >= 1) tag = image.Substring(tagIndex + 1);
148153
if (this.Options.Runtime.ImagePullPolicy == ImagePullPolicy.Always)
149154
{
150-
await this.Docker.Images.CreateImageAsync(new() { FromImage = this.Options.Runtime.Container.Image, Repo = this.Options.Runtime.ImageRepository }, new(), new Progress<JSONMessage>(), cancellationToken);
155+
await this.Docker.Images.CreateImageAsync(new() { FromImage = this.Options.Runtime.Container.Image, Tag = tag, Repo = this.Options.Runtime.ImageRepository }, new(), new Progress<JSONMessage>(), cancellationToken);
151156
}
152157
else
153158
{
@@ -157,7 +162,7 @@ protected virtual async Task PullWorkerImageAsync(CancellationToken cancellation
157162
}
158163
catch (DockerImageNotFoundException)
159164
{
160-
await this.Docker.Images.CreateImageAsync(new() { FromImage = this.Options.Runtime.Container.Image, Repo = this.Options.Runtime.ImageRepository }, new(), new Progress<JSONMessage>(), cancellationToken);
165+
await this.Docker.Images.CreateImageAsync(new() { FromImage = this.Options.Runtime.Container.Image, Tag = tag, Repo = this.Options.Runtime.ImageRepository }, new(), new Progress<JSONMessage>(), cancellationToken);
161166
}
162167
}
163168
}

0 commit comments

Comments
 (0)