Multicontainer: how to configure persistent storage

Hello,
i’m using the new multicontainer feature.
I’ve successfully built and deployed my microservices using the docker-compose below and everything is fine except for the persistent storage: in folder /mnt/data/resin-data i see only “resin-supervisor” but not my services’ folders.
root@58bba1f:/mnt/data/resin-data# ls -la
total 12
drwxr-xr-x 3 root root 4096 Feb 28 06:08 .
drwxr-xr-x 6 root root 4096 Feb 28 06:08 …
drwxr-xr-x 2 root root 4096 Mar 11 17:48 resin-supervisor

image

Why?

Thank you in advance for your kind help

This is my docker-compose.yml:
version: ‘2’
services:
mynodered:
build: ./mynodered
expose:
- “1880”
privileged: true
restart: always
network_mode: host
volumes:
- /mnt/data/resin-data:/data
mymosquitto:
build: ./mymosquitto
expose:
- “1883”
privileged: true
restart: always
network_mode: host
volumes:
- ‘resin-data:/data’
myinfluxdb:
build: ./myinfluxdb
expose:
- “8086”
privileged: true
restart: always
network_mode: host
volumes:
- /mnt/data/resin-data:/data

Hi @arturol76, we don’t support volume bind-mount and you should use named volumes instead for persisted data.

Something like

    volumes:
      -  dirname:/path/inside/container

See more in our docs regarding what parts of the docker-compose syntax is supported.

To expand on this @arturol76 , you’ll want to make sure you have the named volume defined at the top-level of the docker-compose.yml, in addition to the named volume link in the service, which it seems you have correctly defined in your mymosquitto service.

Something like:

version: '2'
volumes: 
    resin-data:
services:
    mynodered:
        build: ./mynodered
        volumes: 
            - 'resin-data:/data'

I’ll make sure our multicontainer docs are updated to clarify this.

1 Like

I also get:

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

when building this docker-compose.yml:

version: '2'

services:
    telegraf:
        image: arm32v7/telegraf:1.5
        volumes:
            - ./etc/telegraf.conf:/etc/telegraf/telegraf.conf:ro

Any hint on how to migrate this short syntax to named volumes? I just need my local config file to end up in /etc/telegraf.

Alternatively, do you recommend building a custom container and copying the config file there? Something like:

version: '2'

services:
    telegraf:
        build: ./mytelegraf

and ./mytelegraf/Dockerfile would look like:

FROM arm32v7/telegraf:1.5

COPY ./etc/telegraf.conf /etc/telegraf/telegraf.conf

But then I lose the ability to change the configuration on the fly…

1 Like

Hey @lv82, the second way is they way I do it, you can have a look at my mc-demo project where I add a telegraf service that logs metrics to another backend influx instance.

Thanks @shaunmulligan. That sounds reasonable. Nice elaboration on the multicontainer example from the documentation.

On a side note, you might want to update the git clone line in your README.md from:

$ git clone git@github.com:resin-projects/simple-server-node.git

to:

$ git clone git@github.com:shaunmulligan/mc-demo.git

@lv82 good catch, I always just copy a template readme :stuck_out_tongue: I am actually working on an expansion of this project that includes a services for remote logging (probably loggly ), also wanna make use of the balena HEALTHCHECK functionality and generally make a nice “Starter” pack project that will get people going quickly with this type of stuff.

Great idea. Looking forward to it. Templates are very nice to enforce best practices and get everyone started faster.

thank you @zwalchuk for you reply.
I did as you suggested:
image

then i build it and push it to resin.io.
This is what i can see in the “releases” page:
image

the mynodered service starts and works as expected. The point is that the /data folder used by nodered is still not persistent:
image

indeed, if i connect to the host os, i would expect to find a “mynodered” folder but i don’t see anything:
image

What am i doing wrong?

Hey @arturol76,
We’ve actually changed the way we store persistent data, so now rather than keep it in /mnt/data/resin-data/, we create a named volume which can be accessed at /mnt/data/docker/volumes/<APP ID>_resin-data/_data. You can use balena volume ls to see all named volumes.

I’ll add this info to our docs ASAP.

i’m also having the same issue. any solution?

You mean the same issue as @arturol76? Have you tried looking in /mnt/data/docker/volumes/<APP ID>_resin-data/_data, as @zwalchuk recommends? Your data should be there.

Dears @lv82 and @zwalchuk
I confirm that my services’ persistent data is now stored in folder /mnt/data/docker/volumes/_resin-data/_data

Thank you!

I will open another thread to ask whether makes sense to have persistent data on a external usb key and how to do that.

1 Like

Hey @shaunmulligan, would you mind sharing why bind mounts are not supported? Any plans to support them in a near future?

@lv82 I currently don’t have enough context to help you with why we don’t support them now, but with regards to future support of bind mounts, I’d suggest you subscribe to the issue at https://github.com/resin-io/resin-supervisor/issues/643, so that you can get live updates of our progress there.

@shaunmulligan I did just that one month ago when you created the issue. I have received yesterday’s notification. Thanks for the follow-up!

I went to the following- /mnt/data/docker/volumes/<APP ID>_resin-data/_data
What to do now? https://vidmate.onl/vmate/ https://9apps.ooo/download/

Hi, Thanks for reaching out to us.
This thread is pretty long so I would like you to specify what you are trying to achieve , how you are doing it and what fails.
Regards
Thomas

The path you mentioned is wrong brother, you need to change it to a new one and then try again.
9Apps Vidmate