Could not connect to the database docker-compose

815 Views Asked by At

I'm trying to create a docker compose for testlink installation

version: '3.8'
services:
  testlink:
    shm_size: 1g
    image: bitnami/testlink:latest
    depends_on:
      - mariadb-testlink
    ports:
      - "8088:8080"
      - "8443:8443"
    user: root
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
      - TESTLINK_USERNAME=****
      - TESTLINK_PASSWORD=*****
      - TESTLINK_DATABASE_USER=bn_testlink
      - TESTLINK_DATABASE_PASSWORD=bitnami
      - TESTLINK_DATABASE_NAME=bitnami_testlink
      - TESTLINK_DATABASE_HOST=mariadb-testlink
    volumes:
      - testlink_data:/bitnami/testlink
      - testlink_code:/opt/bitnami/testlink
      
    networks:
      - testlink_network

    privileged: true

  mariadb-testlink:
    image: bitnami/mariadb:latest
    shm_size: 2g
    container_name: mariadb-testlink
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
      - MARIADB_USER=bn_testlink
      - MARIADB_PASSWORD=bitnami
      - MARIADB_DATABASE=bitnami_testlink
    volumes:
      - mariadb-data_testlink:/bitnami/mariadb

    networks:
      - testlink_network

networks:
  testlink_network:

volumes:
  testlink_data:
  testlink_code:
  mariadb-data_testlink:
    driver: local
    driver_opts:
      type: 'none'
      o: 'bind'
      device: 'home/$USER/Project/testlink/mariadb/'

When I run

docker-compose -f docker-compose-testlink.yml up -d

MariaDB appears to start up, saying

Starting mariadb in background

But testlink reports

Could not connect to the database
1

There are 1 best solutions below

0
OpenBSDNinja On

You aren't exposing any ports for the database to listen on.

Here is for example a section from my docker-compose that I use to run wordpress that also uses Mysql, but imagine its using Mariadb which is pretty much the same thing in the context of this question:

  db:
    image: public.ecr.aws/bitnami/mysql:8.0
    ports:
      - 3306:3306
    environment:
      MYSQL_DATABASE: wordpress
      MYSQL_ROOT_PASSWORD: REDACTED
      MYSQL_PASSWORD: REDACTED
      MYSQL_USER: wordpressuser
    volumes:
      - mysql_data:/var/lib/mysql