@@ -861,7 +861,7 @@ func (p *DockerProvider) CreateContainer(ctx context.Context, req ContainerReque
861
861
}
862
862
}
863
863
864
- tag := req .Image
864
+ imageName := req .Image
865
865
866
866
env := []string {}
867
867
for envKey , envVar := range req .Env {
@@ -883,7 +883,7 @@ func (p *DockerProvider) CreateContainer(ctx context.Context, req ContainerReque
883
883
884
884
var termSignal chan bool
885
885
// the reaper does not need to start a reaper for itself
886
- isReaperContainer := strings .EqualFold (tag , reaperImage (reaperOpts .ImageName ))
886
+ isReaperContainer := strings .EqualFold (imageName , reaperImage (reaperOpts .ImageName ))
887
887
if ! tcConfig .RyukDisabled && ! isReaperContainer {
888
888
r , err := reuseOrCreateReaper (context .WithValue (ctx , testcontainersdocker .DockerHostContextKey , p .host ), testcontainerssession .SessionID (), p , req .ReaperOptions ... )
889
889
if err != nil {
@@ -907,19 +907,19 @@ func (p *DockerProvider) CreateContainer(ctx context.Context, req ContainerReque
907
907
}
908
908
909
909
for _ , is := range req .ImageSubstitutors {
910
- modifiedTag , err := is .Substitute (tag )
910
+ modifiedTag , err := is .Substitute (imageName )
911
911
if err != nil {
912
- return nil , fmt .Errorf ("failed to substitute image %s with %s: %w" , tag , is .Description (), err )
912
+ return nil , fmt .Errorf ("failed to substitute image %s with %s: %w" , imageName , is .Description (), err )
913
913
}
914
914
915
- p .Logger .Printf ("✍🏼 Replacing image with %s. From: %s to %s\n " , is .Description (), tag , modifiedTag )
916
- tag = modifiedTag
915
+ p .Logger .Printf ("✍🏼 Replacing image with %s. From: %s to %s\n " , is .Description (), imageName , modifiedTag )
916
+ imageName = modifiedTag
917
917
}
918
918
919
919
var platform * specs.Platform
920
920
921
921
if req .ShouldBuildImage () {
922
- tag , err = p .BuildImage (ctx , & req )
922
+ imageName , err = p .BuildImage (ctx , & req )
923
923
if err != nil {
924
924
return nil , err
925
925
}
@@ -937,7 +937,7 @@ func (p *DockerProvider) CreateContainer(ctx context.Context, req ContainerReque
937
937
if req .AlwaysPullImage {
938
938
shouldPullImage = true // If requested always attempt to pull image
939
939
} else {
940
- image , _ , err := p .client .ImageInspectWithRaw (ctx , tag )
940
+ image , _ , err := p .client .ImageInspectWithRaw (ctx , imageName )
941
941
if err != nil {
942
942
if client .IsErrNotFound (err ) {
943
943
shouldPullImage = true
@@ -955,20 +955,20 @@ func (p *DockerProvider) CreateContainer(ctx context.Context, req ContainerReque
955
955
Platform : req .ImagePlatform , // may be empty
956
956
}
957
957
958
- registry , imageAuth , err := DockerImageAuth (ctx , tag )
958
+ registry , imageAuth , err := DockerImageAuth (ctx , imageName )
959
959
if err != nil {
960
- p .Logger .Printf ("Failed to get image auth for %s. Setting empty credentials for the image: %s. Error is:%s" , registry , tag , err )
960
+ p .Logger .Printf ("Failed to get image auth for %s. Setting empty credentials for the image: %s. Error is:%s" , registry , imageName , err )
961
961
} else {
962
962
// see https://github.com/docker/docs/blob/e8e1204f914767128814dca0ea008644709c117f/engine/api/sdk/examples.md?plain=1#L649-L657
963
963
encodedJSON , err := json .Marshal (imageAuth )
964
964
if err != nil {
965
- p .Logger .Printf ("Failed to marshal image auth. Setting empty credentials for the image: %s. Error is:%s" , tag , err )
965
+ p .Logger .Printf ("Failed to marshal image auth. Setting empty credentials for the image: %s. Error is:%s" , imageName , err )
966
966
} else {
967
967
pullOpt .RegistryAuth = base64 .URLEncoding .EncodeToString (encodedJSON )
968
968
}
969
969
}
970
970
971
- if err := p .attemptToPullImage (ctx , tag , pullOpt ); err != nil {
971
+ if err := p .attemptToPullImage (ctx , imageName , pullOpt ); err != nil {
972
972
return nil , err
973
973
}
974
974
}
@@ -983,7 +983,7 @@ func (p *DockerProvider) CreateContainer(ctx context.Context, req ContainerReque
983
983
984
984
dockerInput := & container.Config {
985
985
Entrypoint : req .Entrypoint ,
986
- Image : tag ,
986
+ Image : imageName ,
987
987
Env : env ,
988
988
Labels : req .Labels ,
989
989
Cmd : req .Cmd ,
@@ -1079,7 +1079,7 @@ func (p *DockerProvider) CreateContainer(ctx context.Context, req ContainerReque
1079
1079
c := & DockerContainer {
1080
1080
ID : resp .ID ,
1081
1081
WaitingFor : req .WaitingFor ,
1082
- Image : tag ,
1082
+ Image : imageName ,
1083
1083
imageWasBuilt : req .ShouldBuildImage (),
1084
1084
sessionID : testcontainerssession .SessionID (),
1085
1085
provider : p ,
0 commit comments