diff --git a/src/Testcontainers/Builders/DockerConfig.cs b/src/Testcontainers/Builders/DockerConfig.cs
index 1e84c7fbd..7c0f8af40 100644
--- a/src/Testcontainers/Builders/DockerConfig.cs
+++ b/src/Testcontainers/Builders/DockerConfig.cs
@@ -1,4 +1,4 @@
-namespace DotNet.Testcontainers.Builders
+namespace DotNet.Testcontainers.Builders
{
using System;
using System.IO;
diff --git a/src/Testcontainers/Builders/SourceGenerationContext.cs b/src/Testcontainers/Builders/SourceGenerationContext.cs
index f7993d8ef..525008b84 100644
--- a/src/Testcontainers/Builders/SourceGenerationContext.cs
+++ b/src/Testcontainers/Builders/SourceGenerationContext.cs
@@ -1,4 +1,4 @@
-namespace DotNet.Testcontainers.Builders
+namespace DotNet.Testcontainers.Builders
{
using System.Text.Json.Serialization;
diff --git a/src/Testcontainers/Clients/DockerImageOperations.cs b/src/Testcontainers/Clients/DockerImageOperations.cs
index 041cd63e2..fb54c75b9 100644
--- a/src/Testcontainers/Clients/DockerImageOperations.cs
+++ b/src/Testcontainers/Clients/DockerImageOperations.cs
@@ -59,8 +59,7 @@ public async Task CreateAsync(IImage image, IDockerRegistryAuthenticationConfigu
{
var createParameters = new ImagesCreateParameters
{
- FromImage = image.FullName.Replace(":" + image.Tag, string.Empty), // Workaround until https://github.com/dotnet/Docker.DotNet/issues/595 is fixed.
- Tag = image.Tag,
+ FromImage = image.FullName
};
var authConfig = new AuthConfig
diff --git a/src/Testcontainers/Images/DockerImage.cs b/src/Testcontainers/Images/DockerImage.cs
index f5f2ba00c..b113a5207 100644
--- a/src/Testcontainers/Images/DockerImage.cs
+++ b/src/Testcontainers/Images/DockerImage.cs
@@ -1,4 +1,4 @@
-namespace DotNet.Testcontainers.Images
+namespace DotNet.Testcontainers.Images
{
using System;
using System.Globalization;
@@ -117,7 +117,16 @@ public DockerImage(
public string Digest => _digit;
///
- public string FullName => $"{Registry}/{Repository}:{Tag}".Trim(TrimChars);
+ public string FullName
+ {
+ get
+ {
+ var registry = string.IsNullOrEmpty(Registry) ? string.Empty : $"{Registry}/";
+ var tag = string.IsNullOrEmpty(Tag) ? string.Empty : $":{Tag}";
+ var digest = string.IsNullOrEmpty(Digest) ? string.Empty : $"@{Digest}";
+ return $"{registry}{Repository}{tag}{digest}";
+ }
+ }
///
[Obsolete("We will remove this property, it does not follow the DSL. Use the 'Repository' property instead.")]
diff --git a/tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs b/tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs
index bbcb8fea2..bc4235b88 100644
--- a/tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs
+++ b/tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs
@@ -535,6 +535,23 @@ await container.StartAsync()
Assert.EndsWith(name, container.Name);
}
+ [Fact]
+ public async Task PullDigest()
+ {
+ // Given
+ await using var container = new ContainerBuilder()
+ .WithImage("alpine@sha256:3451da08fc6ef554a100da3e2df5ac6d598c82f2a774d5f6ed465c3d80cd163a")
+ .WithEntrypoint(CommonCommands.SleepInfinity)
+ .Build();
+
+ // When
+ var exception = await Record.ExceptionAsync(() => container.StartAsync())
+ .ConfigureAwait(true);
+
+ // Then
+ Assert.Null(exception);
+ }
+
[Fact]
public async Task PullPolicyNever()
{
diff --git a/tests/Testcontainers.Tests/Unit/Images/TestcontainersImageTest.cs b/tests/Testcontainers.Tests/Unit/Images/TestcontainersImageTest.cs
index 7e25ed0d6..1f23c6bc6 100644
--- a/tests/Testcontainers.Tests/Unit/Images/TestcontainersImageTest.cs
+++ b/tests/Testcontainers.Tests/Unit/Images/TestcontainersImageTest.cs
@@ -52,7 +52,7 @@ public void ShouldNotThrowArgumentExceptionIfImageTagHasUppercaseCharacters(stri
[Theory]
[ClassData(typeof(DockerImageFixture))]
- public void WhenImageNameGetsAssigned(DockerImageFixtureSerializable serializable, string image, string _)
+ public void WhenImageNameGetsAssigned(DockerImageFixtureSerializable serializable, string image, string fullName)
{
// Given
var expected = serializable.Image;
@@ -67,7 +67,7 @@ public void WhenImageNameGetsAssigned(DockerImageFixtureSerializable serializabl
Assert.Equal(expected.Digest, actual.Digest);
Assert.Equal(expected.FullName, actual.FullName);
Assert.Equal(expected.Name, actual.Name);
- // Assert.Equal(fullName, actual.FullName);
+ Assert.Equal(fullName, actual.FullName);
}
[Fact]