Can't connect to DB with Docker Compose Setup

Hi,

I’m trying to setup Invoiceplane on my Ubuntu 22.04.1 LTS Server with the following Docker Compose:

version: '3.5'

# docker stack deploy --compose-file stack-invoiceplane.yml invoiceplane

volumes:
  invoiceplane_data:
  mariadb_10_4:

services:
  invoiceplane:
    image: mhzawadi/invoiceplane
    volumes:
      - invoiceplane_data:/var/www/html/uploads
    environment:
      - TZ=utc
      - MYSQL_HOST=db
      - MYSQL_USER=invoicePlane
      - MYSQL_PASSWORD=invoiceplane
      - MYSQL_DB=invoicePlane
      - MYSQL_PORT=3306 
      - IP_URL=http://192.168.178.81:1084 # Ip Adress of server and Port used for Invoiceplane
      - DISABLE_SETUP=false
    ports:
      - "1084:80"
  db:
    image: mariadb:10.4.10
    volumes:
      - mariadb_10_4:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=mysql_password
      - MYSQL_DATABASE=invoiceplane
      - MYSQL_USER=invoiceplane
      - MYSQL_PASSWORD=invoiceplane

I can acess the setup under and everything is ticked right but when setting up the database, no matter what DB Host im typing in (localhost, db, 192.168.0.2) I get the error Message:

Failure
Cannot connect to the database server with the provided database information. Please check the credentials and try again.

How do I correctly connect to my DB?

Hi Thomas, welcome
Open your ipconfig.php and go to the DB_PASSWORD line.
Place your password between quotes, let’s make them single quotes for now.
What did you place for your DB_HOSTNAME? I usually use ‘db’

Hi,
I changed the ipconfig.php and added singel quotes but I still get the same error message. My DB_HOSTNAME is set to ‘db’

Check /application/logs/ for tour log if there are any error messages.
If not, see if you can work with the environment variables you gave to the db service, the mariadb container:

      - MYSQL_ROOT_PASSWORD=mysql_password
      - MYSQL_DATABASE=invoiceplane
      - MYSQL_USER=invoiceplane
      - MYSQL_PASSWORD=invoiceplane

Just assume that the values you gave in your invoiceplane container just aren’t there.

Difference between invoiceplane and db environment variables: in invoiceplane container (service) you capitalized InvoicePlane.
With the db container (service) it’s plain old lowercase.

Let’s first see if there are any errors

Thanks for the answer, I checked the logs and found no errors. But I got it working for me now, the problem was the IP_URL variable, I had to change it to a webpage (https://invoices.mydomain.com/) and configured the selected port in nginx proxy manager and now everything seems to work flawlessly. Here’s my code in case anyone has the same Problem:

version: '3'

volumes:
  invoiceplane_data:
  
services:
  db:
    image: mysql:5.7
    environment:
      MYSQL_DATABASE: invoiceplane
      MYSQL_USER: invoiceplane
      MYSQL_PASSWORD: your_password
      MYSQL_ROOT_PASSWORD: your_root_password
  web:
    image: mhzawadi/invoiceplane  # Replace with your custom image or use "mhzawadi/invoiceplane"
    environment:
      MYSQL_HOST: db
      MYSQL_DATABASE: invoiceplane
      MYSQL_USER: invoiceplane
      MYSQL_PASSWORD: your_password
      IP_URL: https://invoice.mydomin.com/
    ports:
      - "8983:80"
    volumes:
      - invoiceplane_data:/var/www/html/uploads
    depends_on:
      - db
1 Like

Glad you got it working, man!
Interesting that on ‘localhost’ in that case the connection couldn’t be made.

But hey: problem solved