# Prevent Redownload of unmodified containers

**URL:** <https://forums.balena.io/t/prevent-redownload-of-unmodified-containers/350207>\
**Category:** General\
**Created:** [November 21, 2021, 1:21am UTC](https://forums.balena.io/t/prevent-redownload-of-unmodified-containers/350207 "2021-11-21T01:21:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![merith.tk](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/merith.tk/32/6917_2.png) [@merith.tk](https://forums.balena.io/u/merith.tk)\
**Post date:** [November 21, 2021, 1:21am UTC](https://forums.balena.io/t/prevent-redownload-of-unmodified-containers/350207/1 "2021-11-21T01:21:35Z")

</div>

So I use a raspberrry pi 3b+ with the 64bit balenaOS image. this serves as my octopi server. I then run code-server so I can access my octopi server files as needed.

I recently deployed a krist miner (cryptocurrently for minecraft, holds no real world value), and noticed that when I deployed it with this config

```auto
# ./krist-miner/Dockerfile
FROM golang:alpine3.14

ENV WALLET=k33twky32z

RUN apk update
RUN go install github.com/1lann/krist-miner/cpu-miner@latest

CMD ["sh", "-c", "cpu-miner ${WALLET}"]

```

```auto
# unnessecary code for example removed
version: '2'
services
  krist-miner:
    build: ./krist-miner
    container_name: krist
    environment:
      - WALLET=k6kfp19v9k
    restart: unless-stopped

```

I noticed that it rebuilt the un-modified containers alongside the new one. forcing my pi to download 1.7 gigabytes of data. And it does this every time I make a small config, such as changing an environment variable in a container.

Is there a way I can prevent it from re-building/downloading unmodified containers? My local folder containing my balena config, is a git enabled folder with a git repository on gitlab.

---

<div class="post-metadata">

**Author:** ![shawaj](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/shawaj/32/8203_2.png) [@shawaj](https://forums.balena.io/u/shawaj)\
**Post date:** [November 22, 2021, 4:03pm UTC](https://forums.balena.io/t/prevent-redownload-of-unmodified-containers/350207/2 "2021-11-22T16:03:05Z")

</div>

Delta updates should be standard if you are running a recent version of balenaOS [Delta updates - Balena Documentation](https://www.balena.io/docs/learn/deploy/delta/)

So if you haven’t changed anything in the container it shouldn’t download anything at all AFAIK

Guessing it might be a typo but in the above it should be `services:` not `services`

---

<div class="post-metadata">

**Author:** ![cywang117](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cywang117/32/6307_2.png) [@cywang117](https://forums.balena.io/u/cywang117)\
**Post date:** [November 25, 2021, 1:01am UTC](https://forums.balena.io/t/prevent-redownload-of-unmodified-containers/350207/3 "2021-11-25T01:01:07Z")

</div>

Hi @merith-tk,

By what mechanism do you tell that the Pi is downloading 1.7Gb of data per config change? Could you paste an example of this, such as logs or networking monitoring? Thanks!

Regards,  
Christina

---

<div class="post-metadata">

**Author:** ![cywang117](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cywang117/32/6307_2.png) [@cywang117](https://forums.balena.io/u/cywang117)\
**Post date:** [November 25, 2021, 1:04am UTC](https://forums.balena.io/t/prevent-redownload-of-unmodified-containers/350207/4 "2021-11-25T01:04:28Z")

</div>

I’d suggest specifying the `WALLET` env var via balena’s Device Variables section on the dashboard, instead of adding it to the dockerfile. I’m guessing you are modifying `WALLET` and running `balena push` again, and you can avoid this by using an env var from the dashboard instead.

---

<div class="post-metadata">

**Author:** ![merith.tk](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/merith.tk/32/6917_2.png) [@merith.tk](https://forums.balena.io/u/merith.tk)\
**Post date:** [November 28, 2021, 5:13am UTC](https://forums.balena.io/t/prevent-redownload-of-unmodified-containers/350207/6 "2021-11-28T05:13:46Z")

</div>

The “storage” meter on the dashboard, it reaches nearly full when updating and sits around 1.3gb used now, but when it updates it doubles before it is finnished downloading the updates and then deleting the old one

and the WALLET env is fixed basically, the problem comes from when I tweak even the tiniest setting _anywhere_ in `Dockerfile` or `docker-compose.yml`

---

<div class="post-metadata">

**Author:** ![pranavpeshwe](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pranavpeshwe/32/6948_2.png) [@pranavpeshwe](https://forums.balena.io/u/pranavpeshwe)\
**Post date:** [December 24, 2021, 12:12pm UTC](https://forums.balena.io/t/prevent-redownload-of-unmodified-containers/350207/7 "2021-12-24T12:12:15Z")

</div>

Hello @merith-tk,

> The “storage” meter on the dashboard, it reaches nearly full when updating and sits around 1.3gb used now, but when it updates it doubles before it is finnished downloading the updates and then deleting the old one

I did not clearly understand what you wish to state here ^^. Could you please rephrase?

A reliable (yet easy) way to measure n/w traffic is by using the `ifconfig`command. For every interface `ifconfig` prints the number of bytes sent & received on the last line (for e.g `RX bytes:3366093 (3.2 MiB) TX bytes:3990546 (3.8 MiB)`). The difference between ‘RX bytes:’ after & before containers get updated on the device should give you the precise number of bytes downloaded by your RPi.  
If you are not sure which interface is being used to download the update, then you can refer to the output of `route -n`. That should help you in figuring out the interface being used to reach the Internet.

Thanks and regards,  
Pranav

---

<div class="post-metadata">

**Author:** ![lmbarros](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/lmbarros/32/5710_2.png) [@lmbarros](https://forums.balena.io/u/lmbarros)\
**Post date:** [December 24, 2021, 8:00pm UTC](https://forums.balena.io/t/prevent-redownload-of-unmodified-containers/350207/8 "2021-12-24T20:00:57Z")

</div>

Hi @merith-tk! Just complementing what others have said above: using delta updates (they are enabled by default), your device will only download the changes between the image you are currently running and the new one. If you look at the “storage gauge” on the dashboard you’ll indeed see a relatively large increase in the amount of storage used – but not all of this data is being downloaded. Instead, the data on storage is being reconstructed from the current image you already have and the (typically) small delta that is downloaded.
