@@ -59,11 +59,10 @@ pub fn launch_mpc_container(
5959 let compose_file = render_compose_file ( platform, port_mappings, image_name, manifest_digest) ?;
6060 let compose_path = compose_file. path ( ) . display ( ) . to_string ( ) ;
6161
62- // Remove any existing container from a previous run (by name, independent of compose file)
63- let _ = Command :: new ( "docker" )
64- . args ( [ "rm" , "-f" , MPC_CONTAINER_NAME ] )
65- . output ( ) ;
66-
62+ // The compose file pins a stable top-level project `name`, so the
63+ // container is reused across restarts rather than recreated, preserving its
64+ // logs. Compose recreates it only when the rendered config (e.g. image
65+ // digest) changes.
6766 let run_output = Command :: new ( "docker" )
6867 . args ( [ "compose" , "-f" , & compose_path, "up" , "-d" ] )
6968 . output ( )
@@ -265,4 +264,19 @@ mod tests {
265264 // then
266265 assert ! ( !rendered. contains( "environment:" ) ) ;
267266 }
267+
268+ #[ test]
269+ fn includes_stable_project_name ( ) {
270+ // given
271+ let port_mappings = empty_port_mappings ( ) ;
272+ let digest = sample_digest ( ) ;
273+
274+ // when
275+ let rendered = render ( Platform :: Tee , & port_mappings, & digest) ;
276+
277+ // then — a stable top-level project name keeps Compose reusing the
278+ // container across restarts instead of recreating it (which would wipe
279+ // its logs)
280+ assert ! ( rendered. contains( "name: mpc-node" ) ) ;
281+ }
268282}
0 commit comments