@@ -65,36 +65,49 @@ impl DockerManager {
6565 /// Pull a Docker image if it doesn't exist locally
6666 pub async fn pull_image ( & self , image : & str ) -> Result < ( ) , DockerError > {
6767 debug ! ( "Checking if image needs to be pulled: {}" , image) ;
68- if self . docker . inspect_image ( image) . await . is_err ( ) {
68+
69+ // Check if the image uses :latest or :main tag
70+ let should_always_pull = image. ends_with ( ":latest" ) || image. ends_with ( ":main" ) ;
71+
72+ // Only skip pulling if image exists locally AND it's not a :latest or :main tag
73+ if !should_always_pull && self . docker . inspect_image ( image) . await . is_ok ( ) {
74+ debug ! ( "Image {} already exists locally" , image) ;
75+ return Ok ( ( ) ) ;
76+ }
77+
78+ if should_always_pull {
79+ info ! (
80+ "Image {} uses :latest or :main tag, pulling to ensure we have the newest version" ,
81+ image
82+ ) ;
83+ } else {
6984 info ! ( "Image {} not found locally, pulling..." , image) ;
85+ }
7086
71- // Split image name and tag
72- let ( image_name, tag) = match image. split_once ( ':' ) {
73- Some ( ( name, tag) ) => ( name, tag) ,
74- None => ( image, "latest" ) , // Default to latest if no tag specified
75- } ;
87+ // Split image name and tag
88+ let ( image_name, tag) = match image. split_once ( ':' ) {
89+ Some ( ( name, tag) ) => ( name, tag) ,
90+ None => ( image, "latest" ) , // Default to latest if no tag specified
91+ } ;
7692
77- let options = CreateImageOptions {
78- from_image : image_name,
79- tag,
80- ..Default :: default ( )
81- } ;
93+ let options = CreateImageOptions {
94+ from_image : image_name,
95+ tag,
96+ ..Default :: default ( )
97+ } ;
8298
83- let mut image_stream = self . docker . create_image ( Some ( options) , None , None ) ;
99+ let mut image_stream = self . docker . create_image ( Some ( options) , None , None ) ;
84100
85- while let Some ( info) = image_stream. next ( ) . await {
86- match info {
87- Ok ( create_info) => {
88- debug ! ( "Pull progress: {:?}" , create_info) ;
89- }
90- Err ( e) => return Err ( e) ,
101+ while let Some ( info) = image_stream. next ( ) . await {
102+ match info {
103+ Ok ( create_info) => {
104+ debug ! ( "Pull progress: {:?}" , create_info) ;
91105 }
106+ Err ( e) => return Err ( e) ,
92107 }
93-
94- info ! ( "Successfully pulled image {}" , image) ;
95- } else {
96- debug ! ( "Image {} already exists locally" , image) ;
97108 }
109+
110+ info ! ( "Successfully pulled image {}" , image) ;
98111 Ok ( ( ) )
99112 }
100113
0 commit comments