# Error during "apt-get update"

**URL:** <https://forums.balena.io/t/error-during-apt-get-update/6097>\
**Category:** Product support\
**Created:** [April 17, 2019, 12:46pm UTC](https://forums.balena.io/t/error-during-apt-get-update/6097 "2019-04-17T12:46:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![FransvanHoogstraten](https://avatars.discourse-cdn.com/v4/letter/f/85e7bf/32.png) [@FransvanHoogstraten](https://forums.balena.io/u/FransvanHoogstraten)\
**Post date:** [April 17, 2019, 12:46pm UTC](https://forums.balena.io/t/error-during-apt-get-update/6097/1 "2019-04-17T12:46:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![\_Page](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/_page/32/22_2.png) [@\_Page](https://forums.balena.io/u/_Page)\
**Post date:** [April 17, 2019, 1:07pm UTC](https://forums.balena.io/t/error-during-apt-get-update/6097/3 "2019-04-17T13:07:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![FransvanHoogstraten](https://avatars.discourse-cdn.com/v4/letter/f/85e7bf/32.png) [@FransvanHoogstraten](https://forums.balena.io/u/FransvanHoogstraten)\
**Post date:** [April 17, 2019, 1:58pm UTC](https://forums.balena.io/t/error-during-apt-get-update/6097/4 "2019-04-17T13:58:47Z")

</div>

Thanks!

Unfortunately, it is still failing ☹

---

<div class="post-metadata">

**Author:** ![pcgeek86](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcgeek86/32/1455_2.png) [@pcgeek86](https://forums.balena.io/u/pcgeek86)\
**Post date:** [April 17, 2019, 4:38pm UTC](https://forums.balena.io/t/error-during-apt-get-update/6097/5 "2019-04-17T16:38:21Z")

</div>

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/](https://www.balena.io/docs/reference/base-images/base-images/)

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

RUN apt-get update

```

This worked perfectly for me.

```auto
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

---

<div class="post-metadata">

**Author:** ![FransvanHoogstraten](https://avatars.discourse-cdn.com/v4/letter/f/85e7bf/32.png) [@FransvanHoogstraten](https://forums.balena.io/u/FransvanHoogstraten)\
**Post date:** [April 18, 2019, 7:35am UTC](https://forums.balena.io/t/error-during-apt-get-update/6097/6 "2019-04-18T07:35:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![alnjxn](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/alnjxn/32/1392_2.png) [@alnjxn](https://forums.balena.io/u/alnjxn)\
**Post date:** [April 23, 2019, 12:35am UTC](https://forums.balena.io/t/error-during-apt-get-update/6097/8 "2019-04-23T00:35:39Z")

</div>

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:

```auto
RUN install_packages python3 python3-pip

```

---

<div class="post-metadata">

**Author:** ![zrzka](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/zrzka/32/1612_2.png) [@zrzka](https://forums.balena.io/u/zrzka)\
**Post date:** [April 23, 2019, 12:43pm UTC](https://forums.balena.io/t/error-during-apt-get-update/6097/9 "2019-04-23T12:43:51Z")

</div>

The reason for this is that [Wheezy and Jessie were removed from the mirrors](https://lists.debian.org/debian-devel-announce/2019/03/msg00006.html). I’d recommend to switch to Debian Stretch and to migrate your project to [balenalib](https://www.balena.io/docs/reference/base-images/base-images/) images. Or as a workaround, you can add …

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

```

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

---

<div class="post-metadata">

**Author:** ![FransvanHoogstraten](https://avatars.discourse-cdn.com/v4/letter/f/85e7bf/32.png) [@FransvanHoogstraten](https://forums.balena.io/u/FransvanHoogstraten)\
**Post date:** [April 23, 2019, 1:12pm UTC](https://forums.balena.io/t/error-during-apt-get-update/6097/10 "2019-04-23T13:12:07Z")

</div>

Thanks zrzka! Good to know what caused it.

We are currently actually moving to a newer base image…
