hortio / docker-blynk

Docker container for Blynk server
MIT License
26 stars 18 forks source link

How to configure a database using command line #5

Closed jason1987martis closed 2 years ago

jason1987martis commented 2 years ago

Hi. Ive been been using this docker for a long time and was well satisfied. Until recently a issue popped to attach reports. Couldn't figure out how to attach a database on the docker. Kindly help me. (Beginner level with docker )

kumekay commented 2 years ago

Hi @jason1987martis
Do you mean you cannot bind mount your directory with data? Could you please share error logs or at least commands you are trying to execute

jason1987martis commented 2 years ago

Hi @kumekay. I meant i am not able to edit the db.properties file in the docker and the docker doesn't have the postgres database option. Is there a way where i could install postgres and link it to this running docker. (Hope you've understood me).

Also could you assist me (the command) to get into the shell of this running docker container.

kumekay commented 2 years ago

Ok, now got it, I never used blynk with the DB and don't use blynk at all now, but I think you can still create a local file db.properties with config and then run it with docker-compose like:

version: '3'
volumes:
  blynk-data:
  blynk-db:
  blynk-logs:
services:
  db:
    image: postgres:13-alpine
    restart: unless-stopped
    volumes:
      - blynk-db:/var/lib/postgresql/data
    ports:
      - 5432:5432
    environment:
      POSTGRES_DB: db
      POSTGRES_USER: user
      POSTGRES_PASSWORD: pass
  blynk:
    image: hortio/blynk:latest
    command: ["-dataFolder", "/data", "-serverConfig", "/blynk/server.properties"]
    volumes: 
      - 'blynk-data:/data' 
      - 'blynk-logs:/blynk/logs'
      - './db.properties:/blynk/db.properties'
      - './mail.properties:/blynk/mail.properties'
      - './server.properties:/blynk/server.properties'
    ports:
      - "8080:8080" 
      - "9443:9443"
      ## If you don't want Let's encrypt certificates or have a reverse proxy on port 80,
      ## please comment out line below
      - "80:8080"
    restart: always  

  # Watchtower is a service that periodically checks for versions of your docker containers 
  # and fetches new one. So you always will be up to date.
  watchtower: 
    image: v2tec/watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
jason1987martis commented 2 years ago

Hi @kumekay Thanks for the info.