Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"tar: not found in archive" error when using docker Alpine

I run these command:

docker run -ti --rm alpine
apk add --no-cache curl
curl https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.15.6.tgz | tar xvz --strip 1 package/min

and got error tar: package/min: not found in archive.

I run the same command (curl | tar) in Mac terminal and docker ubuntu, all of them are success.

like image 896
Just4test Avatar asked Oct 15 '25 14:10

Just4test


1 Answers

The tar included in Alpine isn't the usual (GNU) tar, but a component of BusyBox:

/scratch # tar --version
tar (busybox) 1.28.4

Apparently, this version of tar generates a (bogus) error message when run with

tar xvz --strip 1 package/min

(however, at first glance, it created the target directory just fine, so ignoring the error message might be ok).

To get rid of the annoying error, you should install GNU tar and use that:

/scratch # apk add --no-cache tar
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
(1/1) Installing tar (1.31-r0)
Executing busybox-1.28.4-r2.trigger
OK: 7 MiB in 19 packages
/scratch # tar --version
tar (GNU tar) 1.31
<rest of message omitted>

Afterwards, running your original command works without any error messages.

like image 102
Frank Schmitt Avatar answered Oct 18 '25 05:10

Frank Schmitt