Skip to content

Commit

Permalink
Check that there isn't a left-over container of the build
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterDA committed Feb 27, 2023
1 parent 62fb6a8 commit 847955c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/docker_sandbox.ml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ let run ~cancelled ?stdin ~log t config (id:S.id) =
Lwt_result.bind
(secrets_layer ~log config.Config.mount_secrets base_image container docker_argv)
(fun () ->
let* r = Docker.Cmd.exists container in
let* () =
if Result.is_ok r then begin
let `Docker_container name = container in
Log.warn (fun f -> f "Removing left over container %s." name);
Docker.Cmd.rm [ container ]
end else
Lwt.return_unit
in
let stdin = Option.map (fun x -> `FD_move_safely x) stdin in
Docker.Cmd_log.run_result ~log ?stdin ~name:container docker_argv base_image argv)
in
Expand Down

0 comments on commit 847955c

Please sign in to comment.