@@ -3107,24 +3107,57 @@ async def compose_up(compose: PodmanCompose, args: argparse.Namespace) -> int |
3107
3107
.decode ("utf-8" )
3108
3108
.splitlines ()
3109
3109
)
3110
+ created_containers = []
3110
3111
diff_hashes = [i for i in hashes if i and i != compose .yaml_hash ]
3111
- if ( args .force_recreate and len (hashes ) > 0 ) or len ( diff_hashes ):
3112
+ if args .force_recreate and (hashes or diff_hashes ):
3112
3113
log .info ("recreating: ..." )
3113
3114
down_args = argparse .Namespace (** dict (args .__dict__ , volumes = False , rmi = None ))
3114
3115
await compose .commands ["down" ](compose , down_args )
3115
3116
log .info ("recreating: done\n \n " )
3116
- # args.no_recreate disables check for changes (which is not implemented)
3117
+ else :
3118
+ # args.no_recreate disables check for changes (which is not implemented)
3119
+ # so let's just check for running containers
3120
+ created_containers = (
3121
+ (
3122
+ await compose .podman .output (
3123
+ [],
3124
+ "ps" ,
3125
+ [
3126
+ "--filter" ,
3127
+ f"label=io.podman.compose.project={ compose .project_name } " ,
3128
+ "--filter" ,
3129
+ "status=created" ,
3130
+ "--filter" ,
3131
+ "status=running" ,
3132
+ "-a" ,
3133
+ "--format" ,
3134
+ "{{ .Names }}" ,
3135
+ ],
3136
+ )
3137
+ )
3138
+ .decode ("utf-8" )
3139
+ .splitlines ()
3140
+ )
3141
+ log .debug ("** Existing containers: %s" , created_containers )
3117
3142
3118
3143
await create_pods (compose )
3119
3144
exit_code = 0
3145
+
3120
3146
for cnt in compose .containers :
3121
3147
if cnt ["_service" ] in excluded :
3122
3148
log .debug ("** skipping: %s" , cnt ["name" ])
3123
3149
continue
3124
- podman_args = await container_to_args (compose , cnt , detached = False , no_deps = args .no_deps )
3125
- subproc_exit_code = await compose .podman .run ([], "create" , podman_args )
3126
- if subproc_exit_code is not None and subproc_exit_code != 0 :
3127
- exit_code = subproc_exit_code
3150
+
3151
+ if args .force_recreate or cnt ["name" ] not in created_containers :
3152
+ podman_args = await container_to_args (
3153
+ compose , cnt , detached = False , no_deps = args .no_deps
3154
+ )
3155
+ subproc_exit_code = await compose .podman .run ([], "create" , podman_args )
3156
+
3157
+ if subproc_exit_code is not None and subproc_exit_code != 0 :
3158
+ exit_code = subproc_exit_code
3159
+ else :
3160
+ subproc_exit_code = 0
3128
3161
3129
3162
if not args .no_start and args .detach and subproc_exit_code is not None :
3130
3163
container_exit_code = await run_container (
0 commit comments