Docker build exits with exit code: 1 [duplicate] - docker

This question already has answers here:
The command '/bin/sh -c apt-get install dnsutils' returned a non-zero code: 1
(2 answers)
Closed 1 year ago.
The aim is to have a Docker CLI in a Container, so I can Communicate with the Host Daemon from within this Container. Therefore I wanted to connect the socket's in the run Command.
I have a Dockerfile with the following start. The rest of the build works fine when I omit the Curl and Docker CLI part.
FROM ubuntu:20.04 as build
#might be even more slim, yet has not yet been tested: debian-stable-slim
RUN apt-get update \
&& apt-get install -y wget
RUN apt-get update && \
apt-get -y install sudo
RUN apt-get update && \
apt-get install curl
## Install Docker CLI:
ENV DOCKERVERSION=20.10.9
RUN sudo curl https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKERVERSION}.tgz \
&& tar xzvf docker-${DOCKERVERSION}.tgz --strip 1 \
-C /usr/local/bin docker/docker \
&& rm docker-${DOCKERVERSION}.tgz
This is the build log with error message:
[+] Building 3.2s (8/9)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 567B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:20.04 1.2s
=> [auth] library/ubuntu:pull token for registry-1.docker.io 0.0s
=> [1/5] FROM docker.io/library/ubuntu:20.04#sha256:626ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288f3322 0.0s
=> CACHED [2/5] RUN apt-get update && apt-get install -y wget 0.0s
=> CACHED [3/5] RUN apt-get update && apt-get -y install sudo 0.0s
=> ERROR [4/5] RUN apt-get update && apt-get install curl 1.9s
------
> [4/5] RUN apt-get update && apt-get install curl:
#8 0.395 Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
#8 0.415 Hit:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease
#8 0.441 Hit:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease
#8 0.517 Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
#8 0.623 Reading package lists...
#8 1.142 Reading package lists...
#8 1.631 Building dependency tree...
#8 1.733 Reading state information...
#8 1.836 The following additional packages will be installed:
#8 1.836 krb5-locales libasn1-8-heimdal libbrotli1 libcurl4 libgssapi-krb5-2
#8 1.836 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal
#8 1.836 libheimntlm0-heimdal libhx509-5-heimdal libk5crypto3 libkeyutils1
#8 1.836 libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libldap-common
#8 1.836 libnghttp2-14 libroken18-heimdal librtmp1 libsasl2-2 libsasl2-modules
#8 1.836 libsasl2-modules-db libsqlite3-0 libssh-4 libwind0-heimdal
#8 1.837 Suggested packages:
#8 1.837 krb5-doc krb5-user libsasl2-modules-gssapi-mit
#8 1.837 | libsasl2-modules-gssapi-heimdal libsasl2-modules-ldap libsasl2-modules-otp
#8 1.837 libsasl2-modules-sql
#8 1.866 The following NEW packages will be installed:
#8 1.867 curl krb5-locales libasn1-8-heimdal libbrotli1 libcurl4 libgssapi-krb5-2
#8 1.867 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal
#8 1.867 libheimntlm0-heimdal libhx509-5-heimdal libk5crypto3 libkeyutils1
#8 1.867 libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libldap-common
#8 1.868 libnghttp2-14 libroken18-heimdal librtmp1 libsasl2-2 libsasl2-modules
#8 1.869 libsasl2-modules-db libsqlite3-0 libssh-4 libwind0-heimdal
#8 1.874 0 upgraded, 27 newly installed, 0 to remove and 0 not upgraded.
#8 1.874 Need to get 3197 kB of archives.
#8 1.874 After this operation, 10.5 MB of additional disk space will be used.
#8 1.874 Do you want to continue? [Y/n] Abort.
------
executor failed running [/bin/sh -c apt-get update && apt-get install curl]: exit code: 1
there is no possibility to choose Y/n, because it exits instantly. Has anyone a Idea how to solve this?
Im Using Docker on Windows, Version 20.10.8
Thanks a lot!

apt get install will wait for user input. You're missing the -y flag to allow it to continue without human intervention:
RUN apt-get update && \
apt-get install -y curl

Related

Error building docker image for a simple rust application: extra-runtime-dependencies package not found?

Anyone try building a rust image using the directions on docker hub? https://hub.docker.com/_/rust
FROM rust:1.40 as builder
WORKDIR /usr/src/myapp
COPY . .
RUN cargo install --path .
FROM debian:buster-slim
RUN apt-get update && apt-get install -y extra-runtime-dependencies && rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/cargo/bin/myapp /usr/local/bin/myapp
CMD ["myapp"]
When I tried to build it using docker build -t myapp, I got an error:
=> CACHED [stage-1 1/3] FROM docker.io/library/debian:buster-slim#sha256:5dbce817ee72802025a38a388237b0ea576aa16 0.0s
=> ERROR [stage-1 2/3] RUN apt-get update && apt-get install -y extra-runtime-dependencies && rm -rf /var/lib/ap 5.4s
------
> [stage-1 2/3] RUN apt-get update && apt-get install -y extra-runtime-dependencies && rm -rf /var/lib/apt/lists/*:
#6 0.617 Get:1 http://deb.debian.org/debian buster InRelease [122 kB]
#6 0.698 Get:2 http://deb.debian.org/debian-security buster/updates InRelease [34.8 kB]
#6 0.731 Get:3 http://deb.debian.org/debian buster-updates InRelease [56.6 kB]
#6 0.875 Get:4 http://deb.debian.org/debian buster/main amd64 Packages [7909 kB]
#6 1.700 Get:5 http://deb.debian.org/debian-security buster/updates/main amd64 Packages [397 kB]
#6 1.734 Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [8788 B]
#6 2.708 Fetched 8529 kB in 2s (3802 kB/s)
#6 2.708 Reading package lists...
#6 3.432 Reading package lists...
#6 4.230 Building dependency tree...
#6 4.443 Reading state information...
#6 4.571 E: Unable to locate package extra-runtime-dependencies
------
executor failed running [/bin/sh -c apt-get update && apt-get install -y extra-runtime-dependencies && rm -rf /var/lib/apt/lists/*]: exit code: 100
The rust documentation needs clarification on this, but extra-runtime-dependencies is a placeholder. Explanation is here

Dockerfile error: The repository 'http://dl.google.com/linux/chrome/deb stable InRelease' is not signed

This dockerfile works when line 4 (case 1) is uncommented, but fails when line 5 (case 2) is uncommented. I have very puzzled by this. The error (if I understand it) should happen in both cases. See the error trace below.
Dockerfile - Case 1 works, case 2 fails
# This is an auto generated Dockerfile for ros:ros-core
# generated from docker_images/create_ros_core_image.Dockerfile.em
# Case 1: Works FROM ubuntu:focal
# Case 2: Gives error FROM dorowu/ubuntu-desktop-lxde-vnc:focal
# setup timezone
RUN apt-get update && \
apt-get install -q -y --no-install-recommends tzdata && \
rm -rf /var/lib/apt/lists/*
# install packages
RUN apt-get update && apt-get install -q -y --no-install-recommends \
dirmngr \
gnupg2 \
&& rm -rf /var/lib/apt/lists/*
# setup sources.list
RUN echo "deb http://packages.ros.org/ros/ubuntu focal main" > /etc/apt/sources.list.d/ros1-latest.list
# setup keys
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
# setup environment
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV ROS_DISTRO noetic
# install ros packages
RUN apt-get update && apt-get install -y --no-install-recommends \
ros-noetic-ros-core=1.5.0-1* \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
ros-noetic-desktop-full
Error Trace
+] Building 0.9s (6/11)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.21kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/dorowu/ubuntu-desktop-lxde-vnc:focal 0.5s
=> [auth] dorowu/ubuntu-desktop-lxde-vnc:pull token for registry-1.docker.io 0.0s
=> CACHED [1/7] FROM docker.io/dorowu/ubuntu-desktop-lxde-vnc:focal#sha256:07e51eafb 0.0s
=> ERROR [2/7] RUN echo 'Etc/UTC' > /etc/timezone && ln -s /usr/share/zoneinfo/E 0.3s
------
> [2/7] RUN echo 'Etc/UTC' > /etc/timezone && ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime && apt-get update && apt-get install -q -y --no-install-recommends tzdata && rm -rf /var/lib/apt/lists/*:
#6 0.307 ln: failed to create symbolic link '/etc/localtime': File exists
------
executor failed running [/bin/sh -c echo 'Etc/UTC' > /etc/timezone && ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime && apt-get update && apt-get install -q -y --no-install-recommends tzdata && rm -rf /var/lib/apt/lists/*]: exit code: 1
~/mydev/dockerplay docker build -t dockerplay3 .
[+] Building 18.5s (5/10)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.11kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/dorowu/ubuntu-desktop-lxde-vnc:focal 0.2s
=> CACHED [1/7] FROM docker.io/dorowu/ubuntu-desktop-lxde-vnc:focal#sha256:07e51eafb 0.0s
=> ERROR [2/7] RUN apt-get update && apt-get install -q -y --no-install-recomme 18.2s
------
> [2/7] RUN apt-get update && apt-get install -q -y --no-install-recommends tzdata && rm -rf /var/lib/apt/lists/*:
#5 1.045 Get:1 http://dl.google.com/linux/chrome/deb stable InRelease [1811 B]
#5 1.046 Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
#5 1.136 Get:3 http://mirrors.ubuntu.com/mirrors.txt Mirrorlist [3393 B]
#5 1.498 Get:4 http://ubuntu.mirror.frontiernet.net/ubuntu focal InRelease [265 kB]
#5 1.612 Ign:6 https://atl.mirrors.clouvider.net/ubuntu focal-backports InRelease
#5 1.651 Get:5 http://mirrors.xmission.com/ubuntu focal-updates InRelease [114 kB]
#5 1.817 Get:6 http://mirrors.gigenet.com/ubuntuarchive focal-backports InRelease [108 kB]
#5 2.547 Err:1 http://dl.google.com/linux/chrome/deb stable InRelease
#5 2.547 The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4EB27DB2A3B88B8B
#5 3.783 Get:7 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [2031 kB]
#5 4.116 Get:8 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [27.5 kB]
#5 4.120 Get:9 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [883 kB]
#5 4.229 Get:10 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [1398 kB]
#5 5.734 Get:13 http://mirror.team-cymru.com/ubuntu focal/universe amd64 Packages [11.3 MB]
#5 5.738 Get:11 http://mirror.uoregon.edu/ubuntu focal/restricted amd64 Packages [33.4 kB]
#5 5.772 Get:14 http://mirrors.arpnetworks.com/Ubuntu focal/multiverse amd64 Packages [177 kB]
#5 5.881 Ign:12 https://mirror.us.leaseweb.net/ubuntu focal/main amd64 Packages
#5 6.256 Get:12 http://mirror.metrocast.net/ubuntu focal/main amd64 Packages [1275 kB]
#5 6.749 Ign:15 http://ftp.usf.edu/pub/ubuntu focal-updates/restricted amd64 Packages
#5 6.837 Ign:15 http://mirrors.arpnetworks.com/Ubuntu focal-updates/restricted amd64 Packages
#5 6.967 Get:17 http://mirrors.namecheap.com/ubuntu focal-updates/universe amd64 Packages [1161 kB]
#5 7.214 Ign:16 https://mirrors.ocf.berkeley.edu/ubuntu-ports focal-updates/multiverse amd64 Packages
#5 7.575 Ign:15 https://mirrors.tscak.com/ubuntu focal-updates/restricted amd64 Packages
#5 8.978 Get:18 http://www.gtlib.gatech.edu/pub/ubuntu focal-updates/main amd64 Packages [2479 kB]
#5 9.766 Get:16 http://repo.miserver.it.umich.edu/ubuntu focal-updates/multiverse amd64 Packages [30.2 kB]
#5 9.927 Get:15 http://mirror.us-ny2.kamatera.com/ubuntu focal-updates/restricted amd64 Packages [1511 kB]
#5 10.24 Get:19 http://reflector.westga.edu/repos/Ubuntu/archive focal-backports/main amd64 Packages [54.2 kB]
#5 10.49 Ign:20 http://mirror.enzu.com/ubuntu focal-backports/universe amd64 Packages
#5 10.85 Ign:20 https://ubuntu.mirror.shastacoe.net/ubuntu focal-backports/universe amd64 Packages
#5 11.07 Ign:20 https://mirrors.ocf.berkeley.edu/ubuntu-ports focal-backports/universe amd64 Packages
#5 11.24 Get:20 http://mirror.umd.edu/ubuntu focal-backports/universe amd64 Packages [27.1 kB]
#5 13.98 Reading package lists...
#5 18.18 W: GPG error: http://dl.google.com/linux/chrome/deb stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4EB27DB2A3B88B8B
#5 18.18 E: The repository 'http://dl.google.com/linux/chrome/deb stable InRelease' is not signed.
------
executor failed running [/bin/sh -c apt-get update && apt-get install -q -y --no-install-recommends tzdata && rm -rf /var/lib/apt/lists/*]: exit code: 100
I believe the public keys for the mentioned repository changed recently, or something like that. Quick fix:
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
Then try again.
I haven't solver this. But I made it go away by removing the lines totally and adding these instead (which I got from another Dockerfile):
RUN apt-get install -y wget
RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt-get install ./google-chrome-stable_current_amd64.deb

Docker ERROR when RUN apt update && apt install -y python3 [duplicate]

This question already exists:
Docker Error when RUN apt install -y python3
Closed last year.
The community reviewed whether to reopen this question last year and left it closed:
Original close reason(s) were not resolved
I am trying to build a new image "first" with a docker file. However, it throws an error with the second line of docker file when I try to build the image.
This is my docker file:
FROM ubuntu:18.10
RUN apt update && apt install -y python3
This is the error message I get:
C:\Users\82104\Desktop\ExerciseFiles>docker build -t first .
[+] Building 2.0s (5/5) FINISHED
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 98B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:18.10 0.0s
=> CACHED [1/2] FROM docker.io/library/ubuntu:18.10 0.0s
=> ERROR [2/2] RUN apt update && apt install -y python3 1.8s
------
> [2/2] RUN apt update && apt install -y python3:
#5 0.539
#5 0.539 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
#5 0.539
#5 0.948 Ign:1 http://archive.ubuntu.com/ubuntu cosmic InRelease
#5 0.948 Ign:2 http://security.ubuntu.com/ubuntu cosmic-security InRelease
#5 1.100 Ign:3 http://archive.ubuntu.com/ubuntu cosmic-updates InRelease
#5 1.100 Err:4 http://security.ubuntu.com/ubuntu cosmic-security Release
#5 1.100 404 Not Found [IP: 91.189.88.152 80]
#5 1.252 Ign:5 http://archive.ubuntu.com/ubuntu cosmic-backports InRelease
#5 1.397 Err:6 http://archive.ubuntu.com/ubuntu cosmic Release
#5 1.397 404 Not Found [IP: 91.189.88.142 80]
#5 1.552 Err:7 http://archive.ubuntu.com/ubuntu cosmic-updates Release
#5 1.552 404 Not Found [IP: 91.189.88.142 80]
#5 1.703 Err:8 http://archive.ubuntu.com/ubuntu cosmic-backports Release
#5 1.703 404 Not Found [IP: 91.189.88.142 80]
#5 1.715 Reading package lists...
#5 1.736 E: The repository 'http://security.ubuntu.com/ubuntu cosmic-security Release' does not have a Release file.
#5 1.736 E: The repository 'http://archive.ubuntu.com/ubuntu cosmic Release' does not have a Release file.
#5 1.736 E: The repository 'http://archive.ubuntu.com/ubuntu cosmic-updates Release' does not have a Release file.
#5 1.736 E: The repository 'http://archive.ubuntu.com/ubuntu cosmic-backports Release' does not have a Release file.
------
executor failed running [/bin/sh -c apt update && apt install -y python3]: exit code: 100
Thanks for your help!

Docker: random Alpine packages fail to install

Context
I have a jenkins that builds a docker image for a raspberry pi 2.
It is using buildx to emulate the ArmV7 environment during build.
This worked great until recently I got random errors during installing the apk packages.
Dockerfile
FROM python:3-alpine
# picam python module
ARG PICAMERA_RELEASE_ADDRESS="{private_repo}"
# Ardafruit python module
ARG ARDAFRUIT_RELEASE_URL="{private_repo}"
WORKDIR /tmp
ENV LD_LIBRARY_PATH="/opt/vc/lib"
COPY ./files /app
RUN apk add --no-cache --verbose \
raspberrypi-libs \
bluez \
bluez-deprecated \
unzip \
git \
glib-dev \
gobject-introspection-dev \
cairo-dev \
py3-cairo \
openssl-dev \
nano \
bash \
alpine-sdk \
&& git clone ${PICAMERA_RELEASE_ADDRESS} \
&& cd picamera \
&& su -c "python3 setup.py install" \
&& cd /tmp/ \
&& git clone ${ARDAFRUIT_RELEASE_URL} \
&& cd Adafruit_Python_DHT \
&& su -c "python3 setup.py install --force-pi2" \
&& cd /tmp/ \
&& CFLAGS="-fcommon" pip3 install \
btlewrap==0.0.* \
Flask==2.* \
waitress==2.* \
flask-cors==3.* \
miflora==0.* \
colorzero==2.* \
RPi.GPIO==0.7.* \
&& cd /tmp/ \
&& chmod +x /app/main.py \
&& chmod +x /app/healthcheck.py \
&& chmod +x /app/harden.sh \
&& apk del \
unzip \
git \
glib-dev \
gobject-introspection-dev \
cairo-dev \
py3-cairo \
openssl-dev \
nano \
bash \
alpine-sdk \
libc-utils \
&& rm -rf /tmp/* \
&& sh /app/harden.sh \
&& rm -f /app/harden.sh \
&& rm -f /bin/rm
# finalize
WORKDIR /app
EXPOSE 80
ENTRYPOINT [ "python3" ]
CMD [ "/app/main.py" ]
HEALTHCHECK --interval=1m --timeout=10s \
CMD python3 /app/healthcheck.py
Pipeline for the build
pipeline {
environment {
registryCredential = ''
registryURL = ''
scmURL = ''
scmCredential = ''
dockerImage = ''
working_branch = ''
working_dir = ''
}
agent any
stages {
stage('Cloning Git') {
steps {
git(
url: scmURL,
credentialsId: scmCredential,
branch: working_branch
)
}
}
stage('docker login') {
steps {
sh '$(aws ecr get-login --no-include-email --region eu-central-1)'
}
}
stage('Build Image and push it') {
steps{
dir(working_dir){
sh "docker build -t $registryURL:latest --platform linux/arm/v7 --push ."
}
}
}
}
}
Jenkins Output
#7 [3/5] COPY ./files /app
#7 DONE 0.0s
#8 [4/5] RUN apk fix && apk add --no-cache --verbose raspberrypi-libs bluez bluez-deprecated unzip git glib-dev gobject-introspection-dev cairo-dev py3-cairo openssl-dev nano bash alpine-sdk && apk fix && git clone https://{private_repo} && cd picamera && su -c "python3 setup.py install" && cd /tmp/ && git clone https://{private_repo} && cd Adafruit_Python_DHT && su -c "python3 setup.py install --force-pi2" && cd /tmp/ && CFLAGS="-fcommon" pip3 install btlewrap==0.0.* Flask==2.* waitress==2.* flask-cors==3.* miflora==0.* colorzero==2.* RPi.GPIO==0.7.* && cd /tmp/ && chmod +x /app/main.py && chmod +x /app/healthcheck.py && chmod +x /app/harden.sh && apk del unzip git glib-dev gobject-introspection-dev cairo-dev py3-cairo openssl-dev nano bash alpine-sdk libc-utils && rm -rf /tmp/* && sh /app/harden.sh && rm -f /app/harden.sh && rm -f /bin/rm
#8 0.337 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/armv7/APKINDEX.tar.gz
#8 1.611 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/armv7/APKINDEX.tar.gz
#8 3.302 OK: 11 MiB in 37 packages
#8 3.581 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/armv7/APKINDEX.tar.gz
#8 4.617 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/armv7/APKINDEX.tar.gz
#8 6.349 (1/130) Installing fakeroot (1.25.3-r3)
#8 6.382 (2/130) Installing openssl (1.1.1l-r0)
#8 6.465 (3/130) Installing libattr (2.5.1-r0)
#8 6.487 (4/130) Installing attr (2.5.1-r0)
#8 6.517 (5/130) Installing libacl (2.2.53-r0)
#8 6.540 (6/130) Installing tar (1.34-r0)
#8 6.632 (7/130) Installing pkgconf (1.7.4-r0)
#8 6.667 (8/130) Installing patch (2.7.6-r7)
#8 6.715 (9/130) Installing libstdc++ (10.3.1_git20210424-r2)
#8 6.894 (10/130) Installing lzip (1.22-r0)
#8 6.929 (11/130) Installing brotli-libs (1.0.9-r5)
#8 7.062 (12/130) Installing nghttp2-libs (1.43.0-r0)
#8 7.101 (13/130) Installing libcurl (7.79.1-r0)
#8 7.185 (14/130) Installing curl (7.79.1-r0)
#8 7.244 (15/130) Installing abuild (3.8.0_rc4-r0)
#8 7.285 Executing abuild-3.8.0_rc4-r0.pre-install
#8 7.296 ERROR: abuild-3.8.0_rc4-r0.pre-install: script exited with error 1
#8 7.321 (16/130) Installing binutils (2.35.2-r2)
#8 7.910 (17/130) Installing libmagic (5.40-r1)
#8 8.140 (18/130) Installing file (5.40-r1)
#8 8.162 (19/130) Installing libgomp (10.3.1_git20210424-r2)
#8 8.226 (20/130) Installing libatomic (10.3.1_git20210424-r2)
#8 8.249 (21/130) Installing libgphobos (10.3.1_git20210424-r2)
#8 8.735 (22/130) Installing gmp (6.2.1-r0)
#8 8.805 (23/130) Installing isl22 (0.22-r0)
#8 8.991 (24/130) Installing mpfr4 (4.1.0-r0)
#8 9.056 (25/130) Installing mpc1 (1.2.1-r0)
#8 9.093 (26/130) Installing gcc (10.3.1_git20210424-r2)
#8 13.99 (27/130) Installing musl-dev (1.2.2-r3)
#8 14.57 (28/130) Installing libc-dev (0.7.2-r3)
#8 14.59 (29/130) Installing g++ (10.3.1_git20210424-r2)
#8 18.44 (30/130) Installing make (4.3-r0)
#8 18.48 (31/130) Installing fortify-headers (1.1-r1)
#8 18.50 (32/130) Installing build-base (0.5-r2)
#8 18.51 (33/130) Installing pcre2 (10.36-r0)
#8 18.58 (34/130) Installing git (2.32.0-r0)
#8 19.63 (35/130) Installing alpine-sdk (1.0-r1)
#8 19.65 (36/130) Installing bash (5.1.4-r0)
#8 19.80 Executing bash-5.1.4-r0.post-install
#8 19.82 ERROR: bash-5.1.4-r0.post-install: script exited with error 1
#8 19.82 (37/130) Installing dbus-libs (1.12.20-r2)
#8 19.88 (38/130) Installing dbus (1.12.20-r2)
#8 19.93 Executing dbus-1.12.20-r2.pre-install
#8 19.94 ERROR: dbus-1.12.20-r2.pre-install: script exited with error 1
#8 19.96 Executing dbus-1.12.20-r2.post-install
#8 19.97 ERROR: dbus-1.12.20-r2.post-install: script exited with error 1
#8 19.97 (39/130) Installing libblkid (2.37.2-r0)
#8 20.04 (40/130) Installing libmount (2.37.2-r0)
#8 20.09 (41/130) Installing pcre (8.44-r0)
#8 20.15 (42/130) Installing glib (2.68.3-r0)
#8 20.46 (43/130) Installing json-c (0.15-r1)
#8 20.52 (44/130) Installing eudev-libs (3.2.10-r0)
#8 20.59 (45/130) Installing bluez (5.58-r2)
#8 20.91 (46/130) Installing bluez-deprecated (5.58-r2)
#8 21.06 (47/130) Installing libxau (1.0.9-r0)
#8 21.08 (48/130) Installing libmd (1.0.3-r0)
#8 21.11 (49/130) Installing libbsd (0.11.3-r0)
#8 21.14 (50/130) Installing libxdmcp (1.1.3-r0)
#8 21.16 (51/130) Installing libxcb (1.14-r2)
#8 21.27 (52/130) Installing libx11 (1.7.2-r0)
#8 21.57 (53/130) Installing libxrender (0.9.10-r3)
#8 21.59 (54/130) Installing libxext (1.3.4-r0)
#8 21.61 (55/130) Installing libpng (1.6.37-r1)
#8 21.65 (56/130) Installing freetype (2.10.4-r1)
#8 21.76 (57/130) Installing fontconfig (2.13.1-r4)
#8 21.86 (58/130) Installing pixman (0.40.0-r2)
#8 21.94 (59/130) Installing cairo (1.16.0-r3)
#8 22.10 (60/130) Installing cairo-tools (1.16.0-r3)
#8 22.20 (61/130) Installing expat-dev (2.4.1-r0)
#8 22.23 (62/130) Installing brotli-dev (1.0.9-r5)
#8 22.26 (63/130) Installing zlib-dev (1.2.11-r3)
#8 22.30 (64/130) Installing libpng-dev (1.6.37-r1)
#8 22.34 (65/130) Installing freetype-dev (2.10.4-r1)
#8 22.46 (66/130) Installing blkid (2.37.2-r0)
#8 22.50 (67/130) Installing libcap-ng (0.8.2-r0)
#8 22.52 (68/130) Installing setpriv (2.37.2-r0)
#8 22.55 (69/130) Installing libsmartcols (2.37.2-r0)
#8 22.60 (70/130) Installing findmnt (2.37.2-r0)
#8 22.64 (71/130) Installing mcookie (2.37.2-r0)
#8 22.67 (72/130) Installing hexdump (2.37.2-r0)
#8 22.70 (73/130) Installing lsblk (2.37.2-r0)
#8 22.75 (74/130) Installing libfdisk (2.37.2-r0)
#8 22.84 (75/130) Installing sfdisk (2.37.2-r0)
#8 22.87 (76/130) Installing cfdisk (2.37.2-r0)
#8 22.91 (77/130) Installing partx (2.37.2-r0)
#8 22.95 (78/130) Installing flock (2.37.2-r0)
#8 22.97 (79/130) Installing logger (2.37.2-r0)
#8 23.00 (80/130) Installing uuidgen (2.37.2-r0)
#8 23.02 (81/130) Installing libeconf (0.3.8-r1)
#8 23.04 (82/130) Installing util-linux (2.37.2-r0)
#8 23.37 (83/130) Installing util-linux-dev (2.37.2-r0)
#8 23.57 (84/130) Installing fontconfig-dev (2.13.1-r4)
#8 23.60 (85/130) Installing xorgproto (2021.4-r0)
#8 23.82 (86/130) Installing libxau-dev (1.0.9-r0)
#8 23.85 (87/130) Installing xcb-proto (1.14.1-r2)
#8 23.91 (88/130) Installing libxdmcp-dev (1.1.3-r0)
#8 23.93 (89/130) Installing libxcb-dev (1.14-r2)
#8 24.08 (90/130) Installing xtrans (1.4.0-r1)
#8 24.13 (91/130) Installing libx11-dev (1.7.2-r0)
#8 24.18 (92/130) Installing libxext-dev (1.3.4-r0)
#8 24.22 (93/130) Installing libxrender-dev (0.9.10-r3)
#8 24.25 (94/130) Installing pixman-dev (0.40.0-r2)
#8 24.27 (95/130) Installing util-macros (1.19.3-r0)
#8 24.30 (96/130) Installing xcb-util (0.4.0-r3)
#8 24.32 (97/130) Installing xcb-util-dev (0.4.0-r3)
#8 24.35 (98/130) Installing cairo-gobject (1.16.0-r3)
#8 24.38 (99/130) Installing mpdecimal (2.5.1-r1)
#8 24.42 (100/130) Installing python3 (3.9.5-r1)
#8 28.02 (101/130) Installing gettext-asprintf (0.21-r0)
#8 28.04 (102/130) Installing libunistring (0.9.10-r1)
#8 28.25 (103/130) Installing gettext-libs (0.21-r0)
#8 28.39 (104/130) Installing libxml2 (2.9.12-r1)
#8 28.57 (105/130) Installing gettext (0.21-r0)
#8 28.70 (106/130) Installing gettext-dev (0.21-r0)
#8 28.95 (107/130) Installing bzip2-dev (1.0.8-r1)
#8 28.97 (108/130) Installing libxml2-utils (2.9.12-r1)
#8 29.00 (109/130) Installing libgpg-error (1.42-r0)
#8 29.07 (110/130) Installing libgcrypt (1.9.4-r0)
#8 29.22 (111/130) Installing libxslt (1.1.34-r1)
#8 29.28 (112/130) Installing docbook-xml (4.5-r6)
#8 29.47 Executing docbook-xml-4.5-r6.post-install
#8 29.47 ERROR: docbook-xml-4.5-r6.post-install: script exited with error 1
#8 29.48 (113/130) Installing docbook-xsl (1.79.2-r2)
#8 30.38 Executing docbook-xsl-1.79.2-r2.post-install
#8 30.39 (114/130) Installing linux-headers (5.10.41-r0)
#8 30.39 ERROR: docbook-xsl-1.79.2-r2.post-install: script exited with error 1
#8 31.04 (115/130) Installing libffi-dev (3.3-r2)
#8 31.09 (116/130) Installing libpcre16 (8.44-r0)
#8 31.14 (117/130) Installing libpcre32 (8.44-r0)
#8 31.19 (118/130) Installing libpcrecpp (8.44-r0)
#8 31.22 (119/130) Installing pcre-dev (8.44-r0)
#8 31.40 (120/130) Installing glib-dev (2.68.3-r0)
#8 31.68 (121/130) Installing cairo-dev (1.16.0-r3)
#8 31.72 (122/130) Installing libltdl (2.4.6-r7)
#8 31.76 (123/130) Installing libtool (2.4.6-r7)
#8 31.99 (124/130) Installing gobject-introspection (1.68.0-r1)
#8 32.10 (125/130) Installing gobject-introspection-dev (1.68.0-r1)
#8 32.61 (126/130) Installing nano (5.7-r2)
#8 32.68 (127/130) Installing openssl-dev (1.1.1l-r0)
#8 32.84 (128/130) Installing py3-cairo (1.20.1-r0)
#8 32.87 (129/130) Installing raspberrypi-libs (0.20200813-r0)
#8 33.12 (130/130) Installing unzip (6.0-r9)
#8 33.19 Executing busybox-1.33.1-r6.trigger
#8 33.33 Executing dbus-1.12.20-r2.trigger
#8 33.48 Executing glib-2.68.3-r0.trigger
#8 33.66 No schema files found: doing nothing.
#8 33.75 5 errors; 167 packages, 603 dirs, 10399 files, 282 MiB
#8 ERROR: process "/dev/.buildkit_qemu_emulator /bin/sh -c apk fix && apk add --no-cache --verbose raspberrypi-libs \t\tbluez bluez-deprecated \t\tunzip git \t\tglib-dev \t\tgobject-introspection-dev \t\tcairo-dev \t\tpy3-cairo \t\topenssl-dev \t\tnano bash alpine-sdk && apk fix && git clone ${PICAMERA_RELEASE_ADDRESS} && cd picamera && su -c \"python3 setup.py install\" && cd /tmp/ && git clone ${ARDAFRUIT_RELEASE_URL} && cd Adafruit_Python_DHT && su -c \"python3 setup.py install --force-pi2\" && cd /tmp/ && CFLAGS=\"-fcommon\" pip3 install btlewrap==0.0.* Flask==2.* waitress==2.* flask-cors==3.* miflora==0.* colorzero==2.* RPi.GPIO==0.7.* && cd /tmp/ && chmod +x /app/main.py && chmod +x /app/healthcheck.py && chmod +x /app/harden.sh && apk del \t\tunzip git \t\tglib-dev \t\tgobject-introspection-dev \t\tcairo-dev \t\tpy3-cairo \t\topenssl-dev \t\tnano bash alpine-sdk libc-utils && rm -rf /tmp/* && sh /app/harden.sh && rm -f /app/harden.sh && rm -f /bin/rm" did not complete successfully: exit code: 5
As you can see there are errors while installing abuild, bash, dbus, docbook-xml and docbook-xsl but these errors are not consistent, on the run before it were only docbook-xsl (the only consistent error) in the run after, abuild and dbus installed successfully.
I am not sure what causes the problem, or how to get more information about the error.
Running the build directly on the raspberry pi works of course, so it seems the error is located somewhere in the multi-arch configuration, but I am not sure what could have changed.
ok, looks like i found my solution here:
https://gitlab.alpinelinux.org/alpine/aports/-/issues/12406
quote from Lyle Franklin:
I hit this error when trying to build a cross-platform ARM64 docker
image from a AMD64 host. However, running docker run --rm --privileged linuxkit/binfmt:v0.8 or update-binfmts --enable prior to running the build seems to avoid the issue. My understanding Docker
will try to use upstream QEMU if it is installed and registered with
the kernel, otherwise Docker will fallback to using a built-in forked
version of QEMU. The build error above only showed up for me with the
forked QEMU.
So I will probably add docker run --rm --privileged linuxkit/binfmt:v0.8 && update-binfmts --enable to my pipeline file if I encounter the error again, for now running it once solved the issue.

How to install yq on Docker image python:3?

What I want to do
I want to install yq to edit some yaml files on a Docker container.
Dockerfile
FROM python:3
RUN apt-get update
RUN apt-key adv --keyserver keyserver.ubuntu.com --keyserver-option http-proxy=http://xxxxxx.com:9999 --recv-keys CC86BB64
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:rmescandon/yq
RUN apt update
RUN apt install yq -y
Reference
https://github.com/mikefarah/yq#on-ubuntu-1604-or-higher-from-debian-package
Build Logs
=> => transferring dockerfile: 486B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/python:3 0.0s
=> CACHED [1/7] FROM docker.io/library/python:3 0.0s
=> [2/7] RUN apt-get update 2.7s
=> [3/7] RUN apt-key adv --keyserver keyserver.ubuntu.com --keyserver-option http-proxy=http://xxxxxx.com:9999 --recv-keys CC86BB64 1.2s
=> [4/7] RUN apt-get install -y software-properties-common 11.4s
=> [5/7] RUN add-apt-repository ppa:rmescandon/yq 13.3s
=> ERROR [6/7] RUN apt update 1.8s
------
> [6/7] RUN apt update:
#9 0.159
#9 0.159 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
#9 0.159
#9 0.205 Hit:1 http://deb.debian.org/debian buster InRelease
#9 0.205 Hit:2 http://security.debian.org/debian-security buster/updates InRelease
#9 0.227 Hit:3 http://deb.debian.org/debian buster-updates InRelease
#9 0.870 Ign:4 http://ppa.launchpad.net/rmescandon/yq/ubuntu impish InRelease
#9 1.356 Err:5 http://ppa.launchpad.net/rmescandon/yq/ubuntu impish Release
#9 1.356 404 Not Found [IP: 91.189.95.85 80]
#9 1.381 Reading package lists...
#9 1.752 E: The repository 'http://ppa.launchpad.net/rmescandon/yq/ubuntu impish Release' does not have a Release file.
------
executor failed running [/bin/sh -c apt update]: exit code: 100
Question
How can I fix it?
TL;DR
The PPA for yq is not available on the python:3 image's Linux distribution.
Change your Dockerfile to download the binary directly instead:
FROM python:3
RUN apt-get update
RUN apt-get install -y wget
# Latest on https://launchpad.net/~rmescandon/+archive/ubuntu/yq is 4.9.6
ARG VERSION=v4.9.6
ARG BINARY=yq_linux_386
RUN wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY} -O /usr/bin/yq \
&& chmod +x /usr/bin/yq
Explanation
The mentioned instructions for installing yq are expecting an Ubuntu-based image, but the python:3 Docker image is based on Debian 10 / Buster (as of the writing of this answer):
Dockerfile for python:3 = python:3.9 = python:3.9.6:
FROM buildpack-deps:buster
$ docker run -it python:3 bash
root#fa97b25dc0d3:/# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root#fa97b25dc0d3:/#
The error
E: The repository 'http://ppa.launchpad.net/rmescandon/yq/ubuntu impish Release' does not have a Release file.
means that the package ppa:rmescandon/yq does not support your distribution. You can check the supports distributions from http://ppa.launchpad.net/rmescandon/yq/ubuntu:
The workaround is to just install it from source or to just download the yq binary itself. This is supported by yq: https://github.com/mikefarah/yq#wget:
wget
Use wget to download the pre-compiled binaries:
Compressed via tar.gz
wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - | tar xz && mv ${BINARY} /usr/bin/yq
Plain binary
wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY} -O /usr/bin/yq && chmod +x /usr/bin/yq
For instance, VERSION=v4.2.0 and BINARY=yq_linux_amd64
Pick out a specific release from yq's Releases page (preferably matching one of the versions distributed for Ubuntu same as in the PPA) and modify your Dockerfile to:
FROM python:3
RUN apt-get update
RUN apt-get install -y wget
# Latest on https://launchpad.net/~rmescandon/+archive/ubuntu/yq is 4.9.6
ARG VERSION=v4.9.6
ARG BINARY=yq_linux_386
RUN wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY} -O /usr/bin/yq \
&& chmod +x /usr/bin/yq
Previous answer did not work in my case.
So this is my alternative solution:
Download the latest executable file of yq from GitHub:
RUN wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
Set execute permission for file:
RUN chmod a+x /usr/local/bin/yq
You can also get the yq in an image using,
FROM docker.io/mikefarah/yq:4.30.6 as yq
FROM python:3
COPY --from=yq "/usr/bin/yq" "/usr/local/bin/yq"
...

Resources