How can I deploy a single container in an multi container environment?

The docs state https://www.balena.io/docs/learn/develop/multicontainer/#multiple-containers

Because each service can be updated independently, larger applications can be developed and maintained by separate teams, each free to work in a way that best supports their service.

But I could not find a way to only build & deploy a single container. How can I do this?

Hi landor, not sure if I understand your question.
If you just need one container and you are using a docker-compose.yml you can always just define one service in that file.
If you are sure you are not going to use more than one service you can use a dockerfile or dockerfile.template in your project as described here https://www.balena.io/docs/learn/develop/dockerfile/ .

Hi and thanks for your answer.

The thing is that I have multiple containers running on the raspberry but I am develping always on only one. When I do balena push app all of the containers get build on the build server. Or at least all the images get downloaded to the build server, checked for changes and then cached layers are used. But anyway this takes time.

What I would like to do is to build & deploy ONLY a single container from my multi-container deployment without touching the others.

Thanks

Sounds like you are trying to streamline your development.

I am not aware that you can instruct the builder to take care of selected containers only.

Have you taken a look at local mode ( https://www.balena.io/docs/learn/develop/local-mode/ ) ? It might not be what you want as images are created locally and on a RPI that might be even slower than recreating the whole project but in the balena cli docu to push ( https://www.balena.io/docs/reference/cli/#push-applicationordevice ) I found this:

When pushing to a local device a live session will be started. The project source folder is watched for filesystem events, and changes to files and folders are automatically synchronized to the running containers. The synchronisation is only in one direction, from this machine to the device, and changes made on the device itself may be overwritten. This feature requires a device running supervisor version v9.7.0 or greater.

Local mode looks nice but for a different use-case. I am currently tying out buidtime / entrypoint things that can only be testet on original hardware.

I’ll just comment out my 3G container for now until fixed that problem.

Thank You.

I’m having this exact issue. I want to set up CI on individual repos and when one is updated, have it deploy as an update to a multicontainer application. Trying balena deploy overwrites all the other containers though, and leaves just the one I deployed. What I want is to be able to update just one of the containers.

Hi

I think what you are trying to do is balena push from a folder - and then whatever is in the folder gets deployed to the app. This is the expected behavior for the balena CLI.

If you want to keep separate git repos for your services, but have them still push to a single app might I suggest that you look into git submodules. In that case, you will be able to have different git projects for each container, and their CI will be able to test that container by itself without making changes to the main app.
And when you need to make changes to the app in the field, you can do it from the original git repo (instead of the submodule).

Does something like that wok for you?

Our current model is using git subtree to do something pretty similar to what you’ve described, but it has the disadvantage of requiring the code to be stored twice, and very precise steps have to be taken to ensure histories are accurate and in sync. From what I’ve read, submodules accomplish largely the same thing.

What we need is a way to push individual images, built in our CI Pipeline, to our multi container apps as one of many containers. Ideally the app would be the same (ie same compose configuration), but with new code for the individual container(s) that was pushed.

Hello, just so I’ve understood correctly, you want your CI pipeline to generate the container images whenever code changes are made, and for the newly generated images to be pushed to the devices in the fleet, without interfering with other containers that haven’t been modified. The codebase used for each of the containers is stored in separate repos. Is this right?

That is exactly correct.

Hi. I don’t believe that updating individual images in a multicontainer app is supported atm. But you could try using balena deploy and a docker-compose.yml containing only the services that should be updated.

If I used balena deploy with a compose only containing the new services, would the other services in the app be affected? In my testing, it seemed that deploy overwrote the existing app.

I’ve created an issue in the balena-cli repo for this feature: https://github.com/balena-io/balena-cli/issues/1923. It will still be discussed, but in the meantime you will have to push the whole application to update.

Thanks, I’ll stay tuned for updates

Also looking for the same solution here. In our case, we may have multiple different developer teams (or even companies) working on an integrated solution that requires updating different containers and their images.

To deploy a single container in a multi-container environment using Balena, you can follow these general steps:

  1. Create a new Balena application: Log in to your Balena account and create a new application. Provide a name for the application and select the target device type.
  2. Set up the application: Once the application is created, you can configure the necessary settings such as the network type, device configuration, and environment variables.
  3. Add a single container service: In the application dashboard, navigate to the “Fleet” tab. Click on the “Add service” button to add a new container service to your application.
  4. Configure the container service: Provide a name for the service and specify the Docker image you want to use for the container. You can specify the image from Docker Hub or your own private registry.
  5. Set up any required environment variables or volumes: If your container requires specific environment variables or volumes to function correctly, you can configure them in the service settings.
  6. Deploy the application: Once the configuration is complete, click on the “Deploy” button to start the deployment process. Balena will build the necessary containers and deploy them to the selected devices in your fleet.

Are there any specific considerations or configurations required to ensure the proper integration of a single container within a multi-container setup?