Error during "apt-get update"

Hey guys,

Yesterday all of sudden I got a weird error during build of my container. I have a few “apt-get update” statements in my dockerfile which keep failing.

I have created a supersmall docker file that shows this behaviour:

FROM resin/%%RESIN_MACHINE_NAME%%-python

RUN apt-get update

The output on the console I get is:

[Info]     Building on arm03
[Info]     Pulling previous images for caching purposes...
[Success]  Successfully pulled cache images
[main]     Step 1/68 : FROM resin/raspberrypi3-python
[main]      ---> 56e5e6de91ac
[main]     Step 2/68 : RUN apt-get update
[main]      ---> Running in 3840477524eb
[main]     Get:1 http://archive.raspbian.org jessie InRelease [15.0 kB]
[main]     Get:2 http://archive.raspberrypi.org jessie InRelease [22.9 kB]
[main]     Get:3 http://security.debian.org jessie/updates InRelease [44.9 kB]
[main]     Ign http://deb.debian.org jessie InRelease
[main]     Get:4 http://deb.debian.org jessie-updates InRelease [7340 B]
[main]     Get:5 http://deb.debian.org jessie Release.gpg [2420 B]
[main]     Get:6 http://deb.debian.org jessie Release [148 kB]
[main]     Get:7 http://archive.raspbian.org jessie/main armhf Packages [13.3 MB]
[main]     Get:8 http://archive.raspberrypi.org jessie/main armhf Packages [170 kB]
[main]     Get:9 http://archive.raspbian.org jessie/contrib armhf Packages [49.5 kB]
[main]     Get:10 http://security.debian.org jessie/updates/main armhf Packages [795 kB]
[main]     Get:11 http://archive.raspbian.org jessie/non-free armhf Packages [106 kB]
[main]     Get:12 http://archive.raspbian.org jessie/rpi armhf Packages [1297 B]
[main]     Get:13 http://archive.raspbian.org jessie/firmware armhf Packages [1208 B]
[main]     Get:14 http://deb.debian.org jessie/main armhf Packages [8898 kB]
[main]     Fetched 23.6 MB in 13s (1703 kB/s)
[main]     W: Failed to fetch http://deb.debian.org/debian/dists/jessie-updates/InRelease  Unable to find expected entry 'main/binary-armhf/Packages' in Release file (Wrong sources.list entry or malformed file)
[main]     E: Some index files failed to download. They have been ignored, or old ones used instead.
[main]     
[main]     Removing intermediate container 3840477524eb
[Info]     Uploading images
[main]     The command '/bin/sh -c apt-get update' returned a non-zero code: 100
[Success]  Successfully uploaded images
[Error]    Some services failed to build:
[Error]      Service: main
[Error]        Error: The command '/bin/sh -c apt-get update' returned a non-zero code: 100
[Error]    Not deploying release.

remote: error: hook declined to update refs/heads/balena-nocache
To git.resin.io:accounts1/alphar3.git
 ! [remote rejected] master -> balena-nocache (hook declined)
error: failed to push some refs to 'accounts1@git.resin.io:accounts1/alphar3.git'

Seems like updating one of the sources is failing. Any of you guys experiencing this as well?

Gr, Frans

1 Like

Hey, could you try the build again please as that looks very much like a transient error with connecting the the debian apt mirrors

Thanks!

Unfortunately, it is still failing :frowning:

Hello,

You might want to start by using the newer balenalib images. Also, have you tried the same reproduction steps on a different device, and on a different network?

https://www.balena.io/docs/reference/base-images/base-images/

FROM balenalib/%%BALENA_MACHINE_NAME%%-python:3

RUN apt-get update

This worked perfectly for me.

user@hostname:~/apt-get-testing123$ balena push HelloBalena
[Info]     Starting build for HelloBalena, user trevor1
[Info]     Dashboard link: https://dashboard.balena-cloud.com/apps/1347452/devices
[Info]     Building on arm03
[Info]     Pulling previous images for caching purposes...
[Success]  Successfully pulled cache images
[main]     Step 1/2 : FROM balenalib/fincm3-python:3
[main]      ---> a793533156d9
[main]     Step 2/2 : RUN apt-get update
[main]      ---> Running in d7cd7299a9a2
[main]     Ign:1 http://deb.debian.org/debian stretch InRelease
[main]     Get:2 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
[main]     Get:3 http://deb.debian.org/debian stretch Release [118 kB]
[main]     Get:4 http://deb.debian.org/debian stretch Release.gpg [2434 B]
[main]     Get:5 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB]
[main]     Get:6 http://deb.debian.org/debian stretch-updates/main armhf Packages [10.8 kB]
[main]     Get:7 http://archive.raspbian.org/raspbian stretch InRelease [15.0 kB]
[main]     Get:8 http://deb.debian.org/debian stretch/main armhf Packages [6913 kB]
[main]     Get:9 http://archive.raspberrypi.org/debian stretch/ui armhf Packages [44.9 kB]
[main]     Get:10 http://archive.raspberrypi.org/debian stretch/main armhf Packages [223 kB]
[main]     Get:11 http://archive.raspbian.org/raspbian stretch/rpi armhf Packages [1360 B]
[main]     Get:12 http://archive.raspbian.org/raspbian stretch/non-free armhf Packages [95.5 kB]
[main]     Get:13 http://archive.raspbian.org/raspbian stretch/contrib armhf Packages [56.9 kB]
[main]     Get:14 http://archive.raspbian.org/raspbian stretch/main armhf Packages [11.7 MB]
[main]     Get:15 http://archive.raspbian.org/raspbian stretch/firmware armhf Packages [1232 B]
[main]     Get:16 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
[main]     Get:17 http://security.debian.org/debian-security stretch/updates/main armhf Packages [470 kB]
[main]     Fetched 19.8 MB in 7s (2675 kB/s)
[main]     Reading package lists...
[main]      ---> 592d609de6e6
[main]     Removing intermediate container d7cd7299a9a2
[main]     Successfully built 592d609de6e6
[Info]     Uploading images
[==================================================>] 100%

Cheers,
Trevor Sullivan

Ok guys thanks, I’ll try using a new base image. Will let you know… :grinning:

I had a similar issue, and updating to a newer base image fixed the issue. I have also been using the RUN install_packages method rather than RUN apt-get, which appears to have some good optimizations if available but I don’t have a good link to documentation on it. example:

RUN install_packages python3 python3-pip

The reason for this is that Wheezy and Jessie were removed from the mirrors. I’d recommend to switch to Debian Stretch and to migrate your project to balenalib images. Or as a workaround, you can add …

RUN sed -i '/jessie-updates/{s/^/#/}' /etc/apt/sources.list

… to your Dockerfile.template before running apt-get.

1 Like

Thanks zrzka! Good to know what caused it.

We are currently actually moving to a newer base image…