MagicMirror issues with bind mounts

Hi,

I am just creating a project that uses the MagicMirror project, but I am having problems because “Bind mounts are not allowed”.

I need to define the ‘~/magic_mirror/config’ and ‘~/magic_mirror/modules’ directory to be able to configure the MagicMirror project. Is there any way to work around that restriction?

Here is my docker-compose.yml:

version: '2'
    services:
      Browser:
        restart: always
        build: ./balena-wpe
        privileged: true
      MagicMirror:
        restart: always
        image: bastilimbach/docker-magicmirror:raspberry
        volumes:
          - ~/magic_mirror/config:/opt/MagicMirror/config
          - ~/magic_mirror/modules:/opt/MagicMirror/modules

@idoodler, thanks for raising this issue and welcome to the balenaCloud forum!

Indeed bind mounts are not supported according to balena’s supported docker-compose fields page:

For the MagicMirror app, I think a workaround would be to use a Dockerfile with a COPY or ADD instruction. Place the Dockerfile in a ‘./magicmirror’ subdirectory of the directory containing the docker-compose.yml file. Then replace the docker-compose image instruction with a build instruction. Something along these lines:

# docker-compose.yml
version: '2'
    services:
      Browser:
        restart: always
        build: ./balena-wpe
        privileged: true
      MagicMirror:
        restart: always
        build: ./magicmirror
# ./magicmirror/Dockerfile
FROM bastilimbach/docker-magicmirror:raspberry
COPY ./config /opt/MagicMirror/config
COPY ./modules /opt/MagicMirror/modules

Before building the image, copy the contents:
from ~/magic_mirror/config to ./magicmirror/config
from ~/magic_mirror/modules to ./magicmirror/modules

This copy is necessary because the source directory of a COPY instruction needs to be relative to the directory containing the Dockerfile – the so-called “build context” directory.

Feel free to ask further questions and let us know how you get on with the project! :slight_smile:

1 Like

Thanks for the answer, I can correctly start the service now.

However, you have a small copy & paste error in your second code block. The second COPY function is the wrong destination directory.

Hey @idoodler

thats great to hear. Thanks for pointing the typo out, I updated the accepted answer.

1 Like