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 jessie InRelease [15.0 kB]
[main]     Get:2 jessie InRelease [22.9 kB]
[main]     Get:3 jessie/updates InRelease [44.9 kB]
[main]     Ign jessie InRelease
[main]     Get:4 jessie-updates InRelease [7340 B]
[main]     Get:5 jessie Release.gpg [2420 B]
[main]     Get:6 jessie Release [148 kB]
[main]     Get:7 jessie/main armhf Packages [13.3 MB]
[main]     Get:8 jessie/main armhf Packages [170 kB]
[main]     Get:9 jessie/contrib armhf Packages [49.5 kB]
[main]     Get:10 jessie/updates/main armhf Packages [795 kB]
[main]     Get:11 jessie/non-free armhf Packages [106 kB]
[main]     Get:12 jessie/rpi armhf Packages [1297 B]
[main]     Get:13 jessie/firmware armhf Packages [1208 B]
[main]     Get:14 jessie/main armhf Packages [8898 kB]
[main]     Fetched 23.6 MB in 13s (1703 kB/s)
[main]     W: Failed to fetch  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]     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
 ! [remote rejected] master -> balena-nocache (hook declined)
error: failed to push some refs to ''

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


Unfortunately, it is still failing :frowning:


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?

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:
[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 stretch InRelease
[main]     Get:2 stretch-updates InRelease [91.0 kB]
[main]     Get:3 stretch Release [118 kB]
[main]     Get:4 stretch Release.gpg [2434 B]
[main]     Get:5 stretch InRelease [25.4 kB]
[main]     Get:6 stretch-updates/main armhf Packages [10.8 kB]
[main]     Get:7 stretch InRelease [15.0 kB]
[main]     Get:8 stretch/main armhf Packages [6913 kB]
[main]     Get:9 stretch/ui armhf Packages [44.9 kB]
[main]     Get:10 stretch/main armhf Packages [223 kB]
[main]     Get:11 stretch/rpi armhf Packages [1360 B]
[main]     Get:12 stretch/non-free armhf Packages [95.5 kB]
[main]     Get:13 stretch/contrib armhf Packages [56.9 kB]
[main]     Get:14 stretch/main armhf Packages [11.7 MB]
[main]     Get:15 stretch/firmware armhf Packages [1232 B]
[main]     Get:16 stretch/updates InRelease [94.3 kB]
[main]     Get:17 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%

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…