8
submitted 7 months ago by sabreW4K3@lemmy.tf to c/docker@programming.dev

I just installed Immich and while all my other containers have just required me to add to them to existing yaml, Immich requires its own yaml. That's fine I guess, but for the library, I wanna host it on my NAS and so I made the volume in my main Docker-Compose.yaml, the Immich yaml was all like, "what you talking about Willis?" because in my Immich environment I tried to point to something created in my main yaml. I thought I could work around this by adding an empty volume declaration, but now I can't find my uploads ๐Ÿ˜‚ any idea on the correct methodology/workaround?

top 4 comments
sorted by: hot top controversial new old
[-] jsalvador@programming.dev 4 points 7 months ago

Answer has been solved but, just in case someone is curious about it: yes, is possible to extend a docker-compose.yaml file with another.

From Docker's docs: https://docs.docker.com/compose/multiple-compose-files/extends/

You can have a common-services.yml file (or whatever name you want to give to it) with a service defined inside, like this:

services:
  webapp:
    build: .
    ports:
      - "8000:8000"
    volumes:
      - "/data"

And then, in your docker-compose.yaml file just extend it with more specific things.

services:
  web:
    extends:
      file: common-services.yml
      service: webapp
[-] mankeulv@lemmy.latrans.cloud 3 points 7 months ago

You cannot reference a part of a docker-compose file from another, but you can have an .env file alongside them where you can declare variables in the format NAME=VALUE, and reference that in the dc files with ${NAME}, assuming your dc files reside alongside each other (with different names) and the .env file itself. I have done this before.

I cannot say if that will work for your use case, as I haven't tried to use the same docker volume in different containers. I don't even know if that is possible, given the possibility of conflicts if both containers tried to access the same files, something to test out, for sure.

[-] sabreW4K3@lemmy.tf 1 points 7 months ago

It doesn't seem to work, as a result, I decided to just add the storage to the Immich yaml, but it's saying that there's an unknown variable still. I'm guessing that's because the environment file doesn't know of the storage. I don't suppose you know how to declare storage in an ENV do you?

[-] Kangie@lemmy.srcfiles.zip 2 points 7 months ago* (last edited 7 months ago)

Use a shared on-disk volume mount, i.e.:

volumes:
  - /data/docker/stuff:/whatever

In both compose files.

I use a similar mechanism to enable my media acquisition stack to grab completed files and store them in their permanent location.

Edit: you can just use the same volume in both containers at the same time, but you'd typically use an NFS mount or something if / when you try and scale this out. You probably just got the volume definition a little off (or need to create it outside both containers definitions and use it there)

this post was submitted on 23 Jan 2024
8 points (100.0% liked)

Docker

966 readers
6 users here now

founded 1 year ago
MODERATORS