Why Balena push created new container for every changes?

Yes I have tried to manually enter the container for debugging purpose but using the image id which is configured properly.

Also as you saw there is issue when the build fails But I faced the same issue even when build succeeded.

Note I am using balena push <ip-address> for pushing the code locally.

@Sharvin26 thanks for the report. I’ve only managed to reproduce this on a failed build, so it appears that we need to do some extra cleanup on a non-failed build.

You mentioned that you saw this one a successful build, is that reproducible?

I’ve made this issue for now, and I’ll try and sort it out asap: https://github.com/balena-io/balena-cli/issues/1236

As it turns out the fix was fairly easy, I’ve put up a PR here: https://github.com/balena-io/balena-cli/pull/1237

@Sharvin26, the fix mentioned by Cameron has been released to the CLI version 10.13.2 (or later). Installation instructions: https://github.com/balena-io/balena-cli/blob/master/INSTALL.md
Let us know if it improves the situation!

The issue for Container has been fixed but it still persists for Image.

➜ balena version
10.13.3

I made some changes in the code and pushed the code locally using balena push <ip-address> and then I got this result:

root@mydevice:~# balena images
REPOSITORY                        TAG                 IMAGE ID            CREATED              SIZE
local_image                latest              d657a18e06c0        About a minute ago   259MB
<none>                            <none>              b9538be2fb0b        17 hours ago         259MB
balena/armv7hf-supervisor         v9.0.1              835f656b8cea        5 months ago         53.5MB


root@mydevice:~# balena ps -a
CONTAINER ID        IMAGE                              COMMAND                  CREATED             STATUS                          PORTS               NAMES
69a1a67f17f9        d657a18e06c0                       "/usr/bin/entry.sh /…"   3 minutes ago       Restarting (0) 36 seconds ago                      local_image_1.1
d2014593293e        balena/armv7hf-supervisor:v9.0.1   "./entry.sh"             19 years ago        Up 8 minutes (healthy)                              resin_supervisor

According to my understanding, it should destroy the old image when it created a new image.

The dangling images are not removed as per normal docker operation. You can delete them yourself by using this helpful command.

docker rmi $(docker images -f "dangling=true" -q)

Yes right now I am using this command

docker rmi $(docker images -f "dangling=true" -q)

Is there any way I can remove them automatically?

At this point, I think the usual way is to manually use the command you just mentioned.

Thanks
ZubairLK

Thanks

I think that this is actually something the supervisor could do, without much of a problem for anything else going on on the device.

I’ve created an issue to track it here: https://github.com/balena-io/balena-supervisor/issues/993

That’s great to know that supervisor can remove the dangling images.