"Bind mounts are not allowed" how to define volumes and pass templates via docker compose?

Hi, first post :slight_smile:

I’ve been fiddling with trying to get a docker-compose driven project running via Balena to see if the tools Balena provides are sufficient for the needs for the project along with other future projects (Deploying via web is so cool! Hope I can make it work). For this project in particular, I’m attempting to convert a docker compose file from v3 to the subset of v2 that balena supports.

I’ve been running into a lot of issues with getting my docker-compose.yml file accepted due to the limited subset of features supported by balena. Some of them I’ve been able to program around via manual pre-build scripts, but others I’m not sure about… largely due to my unfamiliarity with docker but even after poring over the docker and balena docks there are still things I need clarified.

For reference, here’s a link to the file as is, which to the best of my interpretation of the docs should work but does not: https://github.com/jcwilk/funkwhale_rpi_compose/blob/027104e241bbe917685cc0079ea11d64c167a459/docker-compose.yml (the branch is currently figuring_out_bind_mounts_error but just use that ref just in case)

It fails with:

$ git push balena master:master --force
Enumerating objects: 40, done.
Counting objects: 100% (40/40), done.
Delta compression using up to 2 threads
Compressing objects: 100% (39/39), done.
Writing objects: 100% (40/40), 10.64 KiB | 990.00 KiB/s, done.
Total 40 (delta 19), reused 0 (delta 0)

[Error]    Could not parse compose file
[Error]      Bind mounts are not allowed
[Error]    Not deploying release.

remote: error: hook declined to update refs/heads/master
To git.balena-cloud.com:xoxovault/funkwhale.git
 ! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 'xoxovault@git.balena-cloud.com:xoxovault/funkwhale.git'

As best I can tell, the “bind mount points” are the volume definitions? According to the balena docs https://www.balena.io/docs/reference/supervisor/docker-compose/ volumes is supported but you must use short form and name reference “Only support short syntax and named volumes.” so I converted my volumes to be top-level named as per https://docs.docker.com/compose/compose-file/compose-file-v2/#volume-configuration-reference but the error still persists.

Am I interpreting this wrong or is it something else? The error is very unhelpful, it should specify the path in the config or the line number or something to make it clearer what is causing the issue.

Also, I’d like to include an nginx template but I’m not sure how to pass it in without something like:

      - "./nginx/funkwhale.template:/etc/nginx/conf.d/funkwhale.template:ro"

but I’m guessing that isn’t a supported volume type? Are we not allowed to use predefined services and templates at the same time or is there a right way to do this?

Hey @jcwilk

Welcome to the forums!

The volumes which are the problem are these two: https://github.com/jcwilk/funkwhale_rpi_compose/blob/027104e241bbe917685cc0079ea11d64c167a459/docker-compose.yml#L78-L79

This won’t work, as the only thing that is distributed to the device are the images. This means that the path ./nginx/ won’t exist anywhere on device.

My advice would be to alter the Dockerfile to copy these values into the image at the right location at build time, ensuring that they get distributed that way.

Thank you! So I guess I would make a custom image something like this https://stackoverflow.com/a/29902695 since nginx isn’t my docker image?

I think you can get away with something simpler. The problem is mainly to get your files ./nginx/funkwhale.template and ./nginx/funkwhale_proxy.conf into your nginx container . The typical way to do that would be with a dockerfile ( https://www.balena.io/docs/learn/develop/dockerfile/ ). So instead of using the image directive in the docker-compose file us a build/dockerfile directive ( https://docs.docker.com/compose/compose-file/compose-file-v2/#dockerfile ) and place a dockerfile - for instance in the nginx subdirectory.
The dockerfile could be as simple the following. Please take a look at the balena documentation above as to us a Dockerfile.template and a balena base image.

FROM <your image>
COPY ./funkwhale.template  /etc/nginx/conf.d/funkwhale.template
COPY ./funkwhale_proxy.conf /etc/nginx/funkwhale_proxy.conf
CMD <your command>

Sorry for the delay, but thanks for your advice that permitted it to build! It’s exciting seeing the interface for all the different services building and deploying independently.

Sadly I’m getting an error on all of my services that I was running into in a prior attempt also:

17.06.19 18:29:27 (-0700)  redis  standard_init_linux.go:207: exec user process caused "exec format error"
17.06.19 18:29:27 (-0700)  celeryworker  standard_init_linux.go:207: exec user process caused "exec format error"
17.06.19 18:29:27 (-0700)  celeryworker  standard_init_linux.go:207: exec user process caused "exec format error"
17.06.19 18:29:27 (-0700)  api  standard_init_linux.go:207: exec user process caused "exec format error"

“exec format error” sounds like it’s the wrong architecture but I didn’t think I set the architecture anywhere, I thought it would build the correct architecture since it knows which device it’s building for. Did I miss a setting somewhere perhaps? This is building for the balena fin 1.1 and the code is at this commit - https://github.com/jcwilk/funkwhale_rpi_compose/tree/29562febbeec6cf7c92a43b9ff34abccf8b94032

Maybe it’s that all of the images I’m referring to are public images of the wrong architecture as they just assume you always want x64 or something like that? I thought it would build them for the right architecture but perhaps they’re pre-built… Sorry for my ignorance on docker!

Also, this is veering away from the original question so I can start a new topic if I get stuck figuring the new error out if that would help keep things organized.

Hey, so the issue here is that the balena cloud builder doesn’t yet understand image manifests. If it did, the builder could first see which images exist for the architecture that it runs on, but instead it just downloads the default, which is usually x64.

To fix this, you only need to define the image architecture specifically, for example postgres:11 -> arm32v7/postgres:11, redis:3 -> arm32v7/redis:3.

It also appears that the funkwhale image is of the wrong architecture, although I’m not sure how that was created. Likely it would just require a change in base image of the Dockerfile. I did find this repo: https://github.com/thetarkus/docker-funkwhale/blob/master/Dockerfile#L1 which would just require the use of the armv7 alpine base image.

Thanks so much! That makes a lot of sense and saves me a lot of digging, I’ll let you know if I run into any more issues!