1

I have a collection of binary files, which need to be shared by 2 services specified in docker-compose. I need the data to persist on the host OS, but I also need to update it once in a while with new version. Using named volumes I can achieve this using:

volumes:
  data:
    
services:
  myapp:
    image: myimage:latest
    volumes:
      - "data:/opt/data"
    
  anotherapp:
    image: anotherapp:latest
    volumes:
        - "data:/opt/data"

I want to add my binary blobs to a separate container, which can be versioned and pulled from the hub, and files are then placed inside the data volume. I considered using a scratch docker image, or alpine, but scratch container can not be started by docker-compose, as expected.

How can I achieve this configuration and should I even use so-called Data Only Containers, which are advised against? Perhaps myapp itself should download these binary files and place them in persistent storage, in this case I'd have to implement my own versioning/updating logic.

This app runs on balena.io and I'm using docker volume API and balena docs as a reference: https://www.balena.io/docs/learn/develop/multicontainer/#named-volumes

alexm
  • 460
  • 5
  • 14
  • Can you include the files in the two images? Are the two images similar enough that you could build one base image with a language runtime and the files, and then build the two application images from that base? That would avoid most of the complexities of file sharing, and if it's a shared base image, not require more disk space. – David Maze Nov 14 '20 at 12:23
  • @DavidMaze thanks for the comment! Indeed I could include the files in the images themselves, but unfortunately the images are not similar enough to be combined, they run different programming languages and environments. Making an image with files only, with alpine for example, and then doing `COPY --from` is an option I'm considering. – alexm Nov 15 '20 at 03:26

0 Answers0