@@ -117,11 +117,17 @@ export class DockerWorkloadManager implements WorkloadManager {
117117 hostConfig . Memory = opts . machine . memory * 1024 * 1024 * 1024 ;
118118 }
119119
120+ let imageRef = opts . image ;
121+
122+ if ( env . DOCKER_STRIP_IMAGE_DIGEST ) {
123+ imageRef = opts . image . split ( "@" ) [ 0 ] ! ;
124+ }
125+
120126 const containerCreateOpts : Docker . ContainerCreateOptions = {
121127 name : runnerId ,
122128 Hostname : runnerId ,
123129 HostConfig : hostConfig ,
124- Image : opts . image ,
130+ Image : imageRef ,
125131 AttachStdout : false ,
126132 AttachStderr : false ,
127133 AttachStdin : false ,
@@ -133,25 +139,37 @@ export class DockerWorkloadManager implements WorkloadManager {
133139
134140 const logger = this . logger . child ( { opts, containerCreateOpts } ) ;
135141
136- // Ensure the image is present
137- const [ createImageError , imageResponseReader ] = await tryCatch (
138- this . docker . createImage ( this . auth , {
139- fromImage : opts . image ,
140- ...( this . platform ? { platform : this . platform } : { } ) ,
141- } )
142- ) ;
143- if ( createImageError ) {
144- logger . error ( "Failed to pull image" , { error : createImageError } ) ;
145- return ;
146- }
142+ const [ inspectError ] = await tryCatch ( this . docker . getImage ( imageRef ) . inspect ( ) ) ;
147143
148- const [ imageReadError , imageResponse ] = await tryCatch ( readAllChunks ( imageResponseReader ) ) ;
149- if ( imageReadError ) {
150- logger . error ( "failed to read image response" , { error : imageReadError } ) ;
151- return ;
152- }
144+ // If the image is not present, try to pull it
145+ if ( inspectError ) {
146+ logger . error ( "Failed to inspect image, trying to pull" , {
147+ error : inspectError ,
148+ image : opts . image ,
149+ } ) ;
153150
154- logger . debug ( "pulled image" , { image : opts . image , imageResponse } ) ;
151+ // Ensure the image is present
152+ const [ createImageError , imageResponseReader ] = await tryCatch (
153+ this . docker . createImage ( this . auth , {
154+ fromImage : imageRef ,
155+ ...( this . platform ? { platform : this . platform } : { } ) ,
156+ } )
157+ ) ;
158+ if ( createImageError ) {
159+ logger . error ( "Failed to pull image" , { error : createImageError } ) ;
160+ return ;
161+ }
162+
163+ const [ imageReadError , imageResponse ] = await tryCatch ( readAllChunks ( imageResponseReader ) ) ;
164+ if ( imageReadError ) {
165+ logger . error ( "failed to read image response" , { error : imageReadError } ) ;
166+ return ;
167+ }
168+
169+ logger . debug ( "pulled image" , { image : opts . image , imageResponse } ) ;
170+ } else {
171+ // Image is present, so we can use it to create the container
172+ }
155173
156174 // Create container
157175 const [ createContainerError , container ] = await tryCatch (
0 commit comments