With this zip file, this Node script successfully outputs the files:
const child_process = require('child_process')
const util = require('util')
const exec = util.promisify(child_process.exec)
exec(`unzip -Z1 metamorpR.zip`).then(zip_contents => {
if (zip_contents.stderr) {
throw new Error(`unzip error: ${zip_contents.stderr}`)
}
console.log(zip_contents.stdout)
})
metamorpR.z5
Варианты Прохождения.txt
Интерактивная Литература.pdf
But when I run the script from within Docker, it doesn’t.
Using this Dockerfile:
FROM node:16-alpine
RUN apk add --no-cache unzip
COPY . .
ENTRYPOINT ["node", "unzip.js"]
Build and run (substitute in your container image name):
docker build .
docker run --rm 1dc072
Output:
metamorpR.z5
??????? ????????.txt
???????????? ??????????.pdf
I think this means the locales aren’t set correctly within the Docker image? Any ideas how to fix this?
3
Answers
Thanks to @masseyb's answer, I was able to get it working with this Dockerfile, which basically just installs Node manually into an Ubuntu image. The main downside is the image is twice the size, but it's comparatively simple so that's an acceptable downside to me.
Apparently some versions of unzip that is available from Ubuntu repositories can handle automatic decoding of filenames if you specify the -a switch.
TL;DR
unzip
onalpine
doesn’t appear to supportlocales
.unzip
ondebian
doesn’t appear to supportlocales
either.unzip
onubuntu
supports usinglocales
(however there exists no officialnode
ubuntu
image).On
ubuntu
:… there are no issues in the
unzip
file name output:… however the same build
FROM node:16-bullseye
won’t produce the same results:You could apply this patch during the build, then generate the locales, however
unzip
doesn’t appear to use thelocales
: