What happens when I modify an application?

In Balena Cloud, I’ve created an application, created a device, done a git push balena master.

Then I test the application. and make a change to the overall repo - not just the Dockerfile but other files in the repo. In particular a subdirectory that the Dockerfile will copy to the container, with a

COPY ./ros /ros

Next I update the device with:

git add --all; git commit -m "new version"; git push balena master.

Will the previous state of the /ros in the container (i.e. on the device) affect what it looks like after the second push?

No. You can create a persistent volume though. See this article for more information:


1 Like


  • git push is supported but it’s a legacy way of doing things. We recommend you to move to balena push instead. Read more about it here
  • If you want to have some data persistent on the device, as Caleb mentions, you should use persistent volumes.
1 Like

Will do. Is there any improvement using balena push or do you want to remove the implication that people can use you as their repo? However note that the product still recommends the old way:

Hey there! The idea is that balena push can break from the constraints imposed by git push and allow us to do various interesting things more easily, such as build-time secrets. We plan to keep augmenting the push functionality with more features that wouldn’t be very ergonomic when using plain git

Do balena push assume that I am in the git repo? Do I have to stage and commit before balena push or will it work on any directory tree? And I assume it starts at pwd and recurses down. I assume therefore it doesn’t try to handle things like gitignore and git submodules?

balena push doesn’t assume to be in a git repo actually. It’s not required tostage and commit before running balena push. For the best development flow you should read up on local-mode(https://www.balena.io/docs/learn/develop/local-mode/) This uses balena push to sync changes to files on save.

If you finished development you can deploy your app, this will create a production build and deploy it to your device. The docs here: https://www.balena.io/docs/learn/deploy/deployment/#overview Explain more on how this works, including information on the support for git-submodules are on that page.

One more thing. I used balena push and it hung. I don’t know if it completed successfully. It was sitting at [info] Uploading Images for an hour.

I like using balena push over git push because that way I can push uncommitted changes to see if they will work. It can take dozens of tweaks to a Dockerfile before a build works correctly, with balena push I don’t have to have dozens of non-working commits before I get something that works.

1 Like

Hi @pito, we did have a DNS issue this morning, so it might be worth trying your balena push again to see if it works now. With that said, Caleb is correct, balena push is definitely advantageous for rapid testing, especially when combined with local-mode and live pushes.

I’m now experimenting with local mode as requested. Notice the error I get on the second line of output after doing the balena push – “no docker-compose” …

Livepush does not seem to detect a change. Maybe it’s not looking in the right place? Recall that my directory includes a big subdirectory called ros which is copied in one fell swoop in my Dockerfile.template with COPY ./ros /ros

If I change a file in that directory ros/ it seems that it is not detected by live push, and doing another balena push also does not send it to the device.

Is that intended? How do I force it to still send it to the device?

The --nocache flag can be appended if your changes are not being detected, and will force it to be sent to the device:

Thanks I will try that. But is that the expected behavior? In other words that files in such a file are not part of the livepush? Also I assume the “No Docker-Compose” is not a problem, right?

Even with nocache it built the older version of the original files. In other words the problem seems to have been that the source files that it started with were an old version, not intermediate build results. When I switched local off it worked

Hi @pitosalas,

I could not reproduce the behavior you described.

I created a new application and flashed a RPi device with it. I enabled local mode on the device.

The application is minimal:

FROM balenalib/%%BALENA_MACHINE_NAME%%-alpine

COPY ./files /files

CMD ["sleep", "infinity"]

The files folder contains some text files.

I pushed the application to the device in local mode. Then I checked the contents of the file I wanted to modify in files. After this I changed its content. The balena CLI detected the change and updated the container. Afterwards I rechecked the content of the same file on the device and it was updated. Here are the logs from my test:

$ balena push 92c8df3.local
[Info]    Starting build on device
[Info]    No "docker-compose.yml" file found at "."
[Info]    Creating default composition with source: "."
[Build]   [main] Step 1/5 : FROM balenalib/raspberrypi4-64-alpine
[Build]   [main]  ---> 0b9a47130779
[Build]   [main] Step 2/5 : COPY ./files /files
[Build]   [main]  ---> 7f6dbf97a087
[Build]   [main] Step 3/5 : CMD ["sleep", "infinity"]
[Build]   [main]  ---> Running in 589037e427ab
[Build]   [main] Removing intermediate container 589037e427ab
[Build]   [main]  ---> 66cf9135cee0
[Build]   [main] Step 4/5 : LABEL io.resin.local.image=1
[Build]   [main]  ---> Running in 5863cec48e98
[Build]   [main] Removing intermediate container 5863cec48e98
[Build]   [main]  ---> 1dd0afc98bc5
[Build]   [main] Step 5/5 : LABEL io.resin.local.service=main
[Build]   [main]  ---> Running in cfb5a8c74bfb
[Build]   [main] Removing intermediate container cfb5a8c74bfb
[Build]   [main]  ---> abacaa6924b6
[Build]   [main] Successfully built abacaa6924b6
[Build]   [main] Successfully tagged local_image_main:latest

[Live]    Waiting for device state to settle...
[Info]    Streaming device logs...
[Live]    Watching for file changes...
[Logs]    [8/31/2020, 4:28:57 PM] Creating network 'default'
[Logs]    [8/31/2020, 4:28:57 PM] Creating volume 'resin-data'
[Logs]    [8/31/2020, 4:28:57 PM] Installing service 'main sha256:abacaa6924b6858d94bc2161bb0521530e80824cbce25f59239cd8ba862bd3bf'
[Logs]    [8/31/2020, 4:29:01 PM] Installed service 'main sha256:abacaa6924b6858d94bc2161bb0521530e80824cbce25f59239cd8ba862bd3bf'
[Logs]    [8/31/2020, 4:29:01 PM] Starting service 'main sha256:abacaa6924b6858d94bc2161bb0521530e80824cbce25f59239cd8ba862bd3bf'
[Logs]    [8/31/2020, 4:29:03 PM] Started service 'main sha256:abacaa6924b6858d94bc2161bb0521530e80824cbce25f59239cd8ba862bd3bf'
[Live]    Device state settled
[Live]    Detected changes for container main, updating...
[Live]    [main] Restarting service...
[Logs]    [8/31/2020, 4:30:41 PM] Service exited 'main sha256:abacaa6924b6858d94bc2161bb0521530e80824cbce25f59239cd8ba862bd3bf'
[Logs]    [8/31/2020, 4:30:44 PM] Restarting service 'main sha256:abacaa6924b6858d94bc2161bb0521530e80824cbce25f59239cd8ba862bd3bf'