Just4test
Just4test

Reputation: 43

"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.

Upvotes: 3

Views: 15688

Answers (1)

Frank Schmitt
Frank Schmitt

Reputation: 30845

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.

Upvotes: 13

Related Questions