diff --git a/pyinfra/connectors/docker.py b/pyinfra/connectors/docker.py index 0a2e867c3..531059843 100644 --- a/pyinfra/connectors/docker.py +++ b/pyinfra/connectors/docker.py @@ -265,17 +265,10 @@ def get_file( ) # Load the temporary file and write it to our file or IO object - with open(temp_filename, encoding="utf-8") as temp_f: + with open(temp_filename, "rb") as temp_f: with get_file_io(filename_or_io, "wb") as file_io: data = temp_f.read() - data_bytes: bytes - - if isinstance(data, str): - data_bytes = data.encode() - else: - data_bytes = data - - file_io.write(data_bytes) + file_io.write(data) finally: os.close(fd) os.remove(temp_filename)