@@ -28,7 +28,10 @@ def copy_between_containers(
2828 of docker cp is also different depending on whether the destination exists.
2929 """
3030 print (f"Copy between containers: { src_path } -> { dest_path } " )
31- with tempfile .TemporaryDirectory () as temp_dir :
31+ # Some weird stuff happening on AWS where /tmp doesn't work properly
32+ dir = Path .home () / "tmp"
33+ dir .mkdir (parents = True , exist_ok = True )
34+ with tempfile .TemporaryDirectory (dir = dir ) as temp_dir :
3235 temp_path = Path (temp_dir ) / Path (src_path ).name
3336
3437 # Copy from source container to temporary local directory
@@ -133,11 +136,11 @@ def create_file_in_container(
133136 Create a file with given content on a Docker container.
134137 Uses a temporary file on the local filesystem for the transfer.
135138 """
136- with tempfile .NamedTemporaryFile (mode = "w" , delete = False ) as tmp_file :
139+ # Some weird stuff happening on AWS where /tmp doesn't work properly
140+ dir = Path .home () / "tmp"
141+ dir .mkdir (parents = True , exist_ok = True )
142+ with tempfile .NamedTemporaryFile (mode = "w" , delete = True , suffix = ".tmp" , dir = dir ) as tmp_file :
137143 tmp_file .write (content )
144+ tmp_file .flush () # Ensure content is written to disk
138145 tmp_file_path = Path (tmp_file .name )
139-
140- try :
141146 copy_to_container (container , tmp_file_path , dest_path )
142- finally :
143- tmp_file_path .unlink () # Clean up the temporary file
0 commit comments