Why does unzip not work in a container but works in host? start of central directory not found; zipfile corrupt

I’m trying to run a shell script that unzips a file in a container.

Any ideas why this would be happening inside a container, but unzips fine outside the container? (same version of unzip on host and in container)

Script: unzip.sh

unzip myfile.zip

I have a 6G zip file. When I unzip in docker container, I get this error message:

unzip myfile.zip
warning [myfile.zip]:  3076609940 extra bytes at beginning or within zipfile
  (attempting to process anyway)
error [myfile.zip]:  start of central directory not found;
  zipfile corrupt.
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)

But outside the container (on host), it unzips fine.

Starting the container (/work is mapped to host dir where zipfile is):

docker run --rm -v $(pwd):/work -it mycontainer unzip.sh

Notes:
Exactly the same version of unzip on the host and in the container.

$ unzip -v
UnZip 6.00 of 20 April 2009, by Debian. Original by Info-ZIP.

Image base: FROM node:22-bookworm-slim

Have you tried using docker cp instead of mounting the file in? Perhaps that could shed some light

But unless the workdir is set to /work in the container, it will be most likely just the container’s root filesystem. Try this:

docker run --rm -v $(pwd):/work -it --workdir /work mycontainer unzip.sh