Resolve "The command '/bin/sh -c apk update && apk add jq' returned a non-zero code: 1"

My base image in the dockerfile is
FROM balenalib/generic-armv7ahf-debian:jessie-build

and I am trying to build by using the following commands
balena build --deviceType beaglebone-black --arch armv7hf --emulated

Can someone please tell me how to fix it.

Hey, apk is only available when using alpine based base images. To install jq in debian based base images, you need to use apt-get.

Thanks @CameronDiver but I am not using apk anywhere in my docker file. I use apt-get to install the libraries. Below is a portion of my Dockerfile. Can you see anything which might be using the apk.

FROM balenalib/generic-armv7ahf-debian:jessie-build

ENV INITSYSTEM on
ENV DBUS_SYSTEM_BUS_ADDRESS unix:path=/host/run/dbus/system_bus_socket

RUN echo “umask 0077” >> /etc/profile

RUN printf “deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main” > /etc/apt/sources.list

#Install unnecessary SDS tools like lftp
RUN apt-get -q update && apt-get install -yq --no-install-recommends
build-essential
cmake
libcurl4-openssl-dev
htpdate
git
libssl-dev
uuid-dev
libunwind8
libunwind8-dev
gettext
libicu-dev
liblttng-ust-dev
unzip
alsa-utils
libasound2-dev
sqlite3
libsqlite3-dev
python-dbus
libglib2.0-bin
qdbus
dbus
libgoogle-glog-dev
libboost-all-dev
&& apt-get clean && rm -rf /var/lib/apt/lists/*

I managed to build your Dockerfile fine, but I had to change the quotes around echo "umask" and printf "deb... - I believe these are caused by mac OS. More importantly I could not reproduce and get the same error that you are. Do you have another Dockerfile in the same directory, or are you executing in the correct place for example? Can you show me the command that you are using the build this image?

@CameronDiver I am also able to build the image when I push my repo to balena online. (If you did that)
I have only one dockerfile in the current directory from where I am running the below command and trying to build it on my local machine as described in the balena build documentation https://www.balena.io/docs/reference/cli/#build-source

dzdo /balena-cli/balena build --deviceType beaglebone-black --arch armv7hf --emulated

Hi @agaurav,

I have confirmed this issue locally and tracked it down to some changes released in 11.7.0. If you can downgrade your CLI to 11.6.1, you should be able to build successfully. I have opened an issue for it as well and we will let you know once it has been fixed.

Thank you for reporting this issue!

2 Likes

@xginn8 @CameronDiver Thanks for looking into this. I am able to build now.

Hi, the issue has been resolved in CLI v11.14.1