Docker: Unzip a local directory - docker

I'm trying to unzip a local zipped directory 'test_dir.zip', but I keep getting this error:
6 0.671 unzip: can't open /test_dir.zip[.zip]
executor failed running [/bin/sh -c unzip /test_dir.zip]: exit code: 1
The line i'm using in my Dockerfile is : RUN unzip /test_dir.zip

Related

How to use docker-abuild in a Dockerfile?

I want to use docker-abuild to build imagemagick in a Dockerfile. I use the following in the Dockerfile:
FROM alpinelinux/docker-abuild as imagickbuilder
COPY imagick/APKBUILD.imagick /home/builder/package/APKBUILD
COPY imagick/APKBUILD.imagick /home/builder/APKBUILD
COPY imagick/disable-avaraging-tests.patch /home/builder/package/disable-avaraging-tests.patch
COPY imagick/webmaster#mycompany.com-5b42f8ed.rsa /home/builder/ssh.rsa
COPY imagick/webmaster#mycompany.com-5b42f8ed.rsa.pub /etc/apk/keys/ssh.rsa.pub
ARG DABUILD_ARCH=aarch64
RUN dabuild -r
# tried abuild -r as well as builder -r
Regardless of what APKBUILD file I have/use, I'm getting the following error while building with docker build -t test .:
#...
#11 [7/7] RUN dabuild -r
#11 sha256:8c6e0fa4c055b4f5bbb7f633a3b4b4009cda31017a26dc48a047fd02466ce60c
#11 0.658 /bin/sh: dabuild: not found
#11 ERROR: executor failed running [/bin/sh -c dabuild -r]: exit code: 127
------
> [7/7] RUN dabuild -r:
------
executor failed running [/bin/sh -c dabuild -r]: exit code: 127
I'm getting the same error with abuild -r and abuilder -r. Any ideas?
JFYI, I'm running this under macOS Monterey 12.2.1 with an M1 Pro MacBook Pro.

How to solve JFrog config read error when building docker image - [Error] open /root/.jfrog/jfrog-cli.conf: read-only file system

I'm building a docker image and getting the error:
=> ERROR [14/36] RUN --mount=type=secret,id=jfrog-cfg,target=/root/.jfrog/jfrog-cli.conf jfrog rt dl --flat artifact 0.7s
------
> [14/36] RUN --mount=type=secret,id=jfrog-cfg,target=/root/.jfrog/jfrog-cli.conf jfrog rt dl --flat artifact/artifact.tar.gz; set -eux; mkdir -p /usr/local/artifact; tar xzf artifact.tar.gz -C /usr/local/; ln -s /usr/local/artifact /usr/local/artifact;:
#22 0.524 [Error] open /root/.jfrog/jfrog-cli.conf: read-only file system
------
failed to solve with frontend dockerfile.v0: failed to solve with frontend gateway.v0: rpc error: code = Unknown desc = failed to build LLB: executor failed running [/bin/bash -eo pipefail -c jfrog rt dl --flat artifact/${ART_TAG}.tar.gz; set -eux; mkdir -p /usr/local/${ART_TAG}; tar xzf ${ART_TAG}.tar.gz -C /usr/local/; ln -s /usr/local/${ART_VERSION} /usr/local/artifact;]: runc did not terminate sucessfully
The command I use to build the docker image is
DOCKER_BUILDKIT=1 docker build -t imagename . --secret id=jfrog-cfg,src=${HOME}/.jfrog/jfrog-cli.conf (jfrog config exists at ${HOME}/.jfrog/jfrog-cli.conf)
JFrog is working and the artifact I'm downloading exists as I can manually download it outside of using docker.
On Linux, docker is run using the root user, so ${HOME} is /root and not /home/your-user-name or whatever your usual home folder is. Try using explicit full pathnames instead of the env var.

Error while building Docker image for Druid

I am doing this tutorial to load batch data using Apache Hadoop and I try to run this command to build a Docker image named "druid-hadoop-demo" with version tag "2.8.5" :
docker build -t druid-hadoop-demo:2.8.5 .
but it gives me this error
Step 14/53 : RUN curl -s https://archive.apache.org/dist/hadoop/core/hadoop-2.8.3/hadoop-2.8.3.tar.gz | tar -xz -C /usr/local/
---> Running in 7baa699ccc29
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now
The command '/bin/sh -c curl -s https://archive.apache.org/dist/hadoop/core/hadoop-2.8.3/hadoop-2.8.3.tar.gz | tar -xz -C /usr/local/' returned a non-zero code: 2
Any help is appreciated.
That's a network error, indicating the file you downloaded was either corrupted in transit (it downloaded correctly for me, so unlikely to be the source), or the connection was dropped before finishing the curl command. Check for network proxies, intermittent network failures, or anything else that could interrupt the connection. You can also try to manually run curl from within a container to see if it's successful, e.g.
curl -o hadoop.tgz https://archive.apache.org/dist/hadoop/core/hadoop-2.8.3/hadoop-2.8.3.tar.gz
tar -tvzf hadoop.tgz

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

Why can't I pipe a file to "tar" from "curl" with a Docker image for Debian?

Why is the following failing on a Docker image for Debian Jessie?
# curl --silent --show-error --location https://download.owncloud.org/community/owncloud-8.0.3.tar.bz2 | tar xjv
tar (grandchild): bzip2: Cannot exec: No such file or directory
tar (grandchild): Error is not recoverable: exiting now
tar: Child died with signal 13
tar: Error is not recoverable: exiting now
curl: (23) Failed writing body (4096 != 16384)
I can't run that inside Dockerfile RUN statements, or in an interactive bash shell for the image "php:5.6-fpm" (based off "debian:jessie").
I can, however, run it on lots of other Debian and Ubuntu systems.
Is this a problem with Docker?
This error message seems pretty clear:
tar (grandchild): bzip2: Cannot exec: No such file or directory
bzip2 isn't present in the debian:jessie instance, so if you want to use bzip2 compression, you have to install bzip2 first with apt-get install bzip2.

Resources