this post was submitted on 15 Aug 2023
7 points (81.8% liked)

Selfhosted

40183 readers
687 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

I have a docker container running in portainer. I have added an SMB volume to the container. Does anyone know how I can update this docker container using docker-compose without undoing my changes? Thanks
@selfhosted @Docker @portainerio

top 8 comments
sorted by: hot top controversial new old
[–] Catsrules@lemmy.ml 4 points 1 year ago (1 children)

You can just mount the SMB volume using docker-compose.

I think have some example compose files if you need some example.

[–] LordChaos82@fosstodon.org 0 points 1 year ago (1 children)

@Catsrules Thanks. This specific to Immich. The upload location in the docker-compose is picked from .env file. I, for the life of me, cannot figure out how to mount the portainer SMB volume in the .env file. What I ended up doing was to select the containers using the upload location and edit the volume to attach the SMB share volume from portainer. I hope what I said makes sense. I am just a newbie learning docker right now.

[–] Catsrules@lemmy.ml 1 points 1 year ago* (last edited 1 year ago)

I am kind of just making this up as I go along so odds are this won't work but it will hopefully get you closer. I only modified the very end under the volumes from their default compose file here https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml

You will need to change the IP address to the address of you SMB server as well as the user name and password your going to be using. You may need to change the uid and gid I think you want those to be the id of whatever user is running immich. 1000 is usually a good default if you don't know.

In the .env file try just putting in upload-volume as the upload location. Like this

UPLOAD_LOCATION=upload-volume

Oh I almost forgot your host computer (the one running docker) needs to have cifs-utils installed or the cifs volume will not work and you will get a bunch of errors (Ask me how I know).

Modified Compose file

version: "3.8"

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: [ "start.sh", "immich" ]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    depends_on:
      - redis
      - database
      - typesense
    restart: always

  immich-microservices:
    container_name: immich_microservices
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    # extends:
    #   file: hwaccel.yml
    #   service: hwaccel
    command: [ "start.sh", "microservices" ]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    depends_on:
      - redis
      - database
      - typesense
    restart: always

  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always

  immich-web:
    container_name: immich_web
    image: ghcr.io/immich-app/immich-web:${IMMICH_VERSION:-release}
    env_file:
      - .env
    restart: always

  typesense:
    container_name: immich_typesense
    image: typesense/typesense:0.24.1@sha256:9bcff2b829f12074426ca044b56160ca9d777a0c488303469143dd9f8259d4dd
    environment:
      - TYPESENSE_API_KEY=${TYPESENSE_API_KEY}
      - TYPESENSE_DATA_DIR=/data
    volumes:
      - tsdata:/data
    restart: always

  redis:
    container_name: immich_redis
    image: redis:6.2-alpine@sha256:70a7a5b641117670beae0d80658430853896b5ef269ccf00d1827427e3263fa3
    restart: always

  database:
    container_name: immich_postgres
    image: postgres:14-alpine@sha256:28407a9961e76f2d285dc6991e8e48893503cc3836a4755bbc2d40bcc272a441
    env_file:
      - .env
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
    volumes:
      - pgdata:/var/lib/postgresql/data
    restart: always

  immich-proxy:
    container_name: immich_proxy
    image: ghcr.io/immich-app/immich-proxy:${IMMICH_VERSION:-release}
    environment:
      # Make sure these values get passed through from the env file
      - IMMICH_SERVER_URL
      - IMMICH_WEB_URL
    ports:
      - 2283:8080
    depends_on:
      - immich-server
      - immich-web
    restart: always

volumes:
  pgdata:
  model-cache:
  tsdata:
  upload-volume:
    driver: local
    driver_opts:
      type: cifs
      device: "//172.1.1.6/changetoshare"
      o: addr=172.1.1.6,username=changetouser,password=changeme,vers=2.0,uid=1000,gid=1000
[–] chiisana@lemmy.chiisana.net 2 points 1 year ago

You'd mount the volume in the docker-compose.yml using the volumes: node.

You can try to automatically generate the compose file via this command:

docker run --rm \
    -v /var/run/docker.sock:/var/run/docker.sock:ro \
    ghcr.io/red5d/docker-autocompose \
    your-current-container-name-or-id-goes-here \
    another-container-should-there-be-more-than-one
[–] portainerio@mastodon.online 1 points 1 year ago

@LordChaos82 @selfhosted you can create a compose file, and in it, state the volumes are external (so compose knows to reuse existing volumes).

[–] Dirk@lemmy.ml 1 points 1 year ago (1 children)

Don’t add the mount in the container. Just open Portainer, go to your container, click “Duplicate/Edit”, scroll down, and do this:

[–] LordChaos82@fosstodon.org 0 points 1 year ago (1 children)

@Dirk thanks. That's how I did it but I am not sure if updating using docker compose would overwrite it. Portainer is running on a VM so I will make sure to snapshot it and try so I can restore it if needed.

[–] Dirk@lemmy.ml 1 points 1 year ago

You’re using Portainer, why manually mess with docker compose?