diff --git a/core/src/main/java/org/testcontainers/utility/MountableFile.java b/core/src/main/java/org/testcontainers/utility/MountableFile.java
index <HASH>..<HASH> 100644
--- a/core/src/main/java/org/testcontainers/utility/MountableFile.java
+++ b/core/src/main/java/org/testcontainers/utility/MountableFile.java
@@ -183,8 +183,8 @@ public class MountableFile implements Transferable {
 
         if (!entry.isDirectory()) {
             // Create parent directories
-            newFile.mkdirs();
-            newFile.delete();
+            Path parent = newFile.getAbsoluteFile().toPath().getParent();
+            parent.toFile().mkdirs();
             newFile.deleteOnExit();
 
             try (InputStream is = jarFile.getInputStream(entry)) {
Stop creation of temporary directory prior to creating temporary file. (#<I>)