Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR ==> Could not connect to the database on *fresh install* #25390

Closed
zoubinho opened this issue Feb 25, 2023 · 10 comments
Closed

ERROR ==> Could not connect to the database on *fresh install* #25390

zoubinho opened this issue Feb 25, 2023 · 10 comments
Assignees
Labels
solved stale 15 days without activity suitecrm tech-issues The user has a technical issue about an application triage Triage is needed

Comments

@zoubinho
Copy link

zoubinho commented Feb 25, 2023

Name and Version

bitnami/suitecrm:latest

What architecture are you using?

amd64

What steps will reproduce the bug?

using instructions on https://github.com/bitnami/containers/tree/main/bitnami/suitecrm

Step 1: Create a network
docker network create suitecrm-network

Step 2: Create a volume for MariaDB persistence and create a MariaDB container

$ docker volume create --name mariadb_data
$ docker run -d --name mariadb \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --env MARIADB_USER=bn_suitecrm \
  --env MARIADB_PASSWORD=bitnami \
  --env MARIADB_DATABASE=bitnami_suitecrm \
  --network suitecrm-network \
  --volume /volume1/data/crm/mariadb_data:/bitnami/mariadb \
  bitnami/mariadb:latest

Step 3: Create volumes for SuiteCRM persistence and launch the container

$ docker volume create --name suitecrm_data
$ docker run -d --name suitecrm \
  -p 8080:8080 -p 8443:8443 \
  --env ALLOW_EMPTY_PASSWORD=yes \
  --env SUITECRM_DATABASE_USER=bn_suitecrm \
  --env SUITECRM_DATABASE_PASSWORD=bitnami \
  --env SUITECRM_DATABASE_NAME=bitnami_suitecrm \
  --network suitecrm-network \
  --volume /volume1/data/crm/suitecrm_data:/bitnami/suitecrm \
  bitnami/suitecrm:latest

mariadb starts correctly, but suitecrm start and stop after 20s with this error stack:

suitecrm 15:45:21.98 INFO  ==> ** Starting SuiteCRM setup **
realpath: /bitnami/apache/conf: No such file or directory
suitecrm 15:45:22.01 INFO  ==> Configuring Apache ServerTokens directive
suitecrm 15:45:22.11 INFO  ==> Configuring PHP options
suitecrm 15:45:22.11 INFO  ==> Setting PHP expose_php option
suitecrm 15:45:22.14 INFO  ==> Validating settings in MYSQL_CLIENT_* env vars
suitecrm 15:45:22.23 INFO  ==> Ensuring SuiteCRM directories exist
suitecrm 15:45:22.24 INFO  ==> Trying to connect to the database server
suitecrm 15:46:22.43 ERROR ==> Could not connect to the database

What is the expected behavior?

expecting service to start and suitecrm to connect to mariadb

What do you see instead?

suitecrm not connecting to mariadb

@zoubinho zoubinho added the tech-issues The user has a technical issue about an application label Feb 25, 2023
@bitnami-bot bitnami-bot added this to Triage in Support Feb 25, 2023
@github-actions github-actions bot added the triage Triage is needed label Feb 25, 2023
@carrodher
Copy link
Member

Please, note that the Bitnami team is not actively monitoring GitHub Issues for this project. This issue will stay open for 20 days to allow the community to contribute, after 15 days without activity the issue will be marked as stale, being closed after 5 days.

If you would like to contribute to this container image by fixing a bug or adding a new feature, feel free to create a PR, the Bitnami team will be happy to review it and provide feedback.

@github-actions github-actions bot moved this from Triage to Pending in Support Feb 26, 2023
@ThiloteE
Copy link

ThiloteE commented Mar 11, 2023

I encountered the same error and with the help of a good friend we managed to fix/work around it.

Down below you see my whole installation process and I hope it will help you and it is not too hard to read :-)


# Guides I followed:

   #https://dexor.de/blog/suitecrm-in-docker/
   #https://github.com/bitnami/containers/tree/main/bitnami/suitecrm#readme

# HOW TO INSTALL
-----------------------------

#Start by installing suitecrm
#https://github.com/bitnami/containers/tree/main/bitnami/suitecrm#readme

   git clone https://github.com/bitnami/containers.git
   # cd bitnami/APP/VERSION/OPERATING-SYSTEM
   cd ~/USER/Suite-CRM-Docker-Setup/containers/bitnami/suitecrm

# Now, change the docker-compose.yml file to include correct environment variables parameter
   # Keep in mind that the path to volumes in mariaDB and suiteCRM should differ!
   # Docker will check during creation of suitecrm config, if path of volume is empty and errors out, if otherwise

   #Example for how it worked for me:

       volumes:
       # - 'mariadb_data:/bitnami/mariadb'
         - '/PATH/TO/PERSISTENCE:/bitnami/mariadb'

       volumes:
       # - 'suitecrm_data:/bitnami/suitecrm'
         - '/PATH/TO/PERSISTENCE/DIFFERENT/DIFFERENTTWO:/bitnami/suitecrm'

   # If the error still triggers, remove following 3 lines during inital setup
   # to create suitecrm or php config with non-persistence.
   # Afterwards add these 3 lines back and try to run the container again with persistence.

       volumes:
       # - 'suitecrm_data:/bitnami/suitecrm'
         - '/PATH/TO/PERSISTENCE/DIFFERENT/DIFFERENTTWO:/bitnami/suitecrm'


# follow https://sysctl-explorer.net/net/ipv4/ip_unprivileged_port_start/
# Add net.ipv4.ip_unprivileged_port_start=0 to /etc/sysctl.conf (or /etc/sysctl.d) by going to /etc/syscctl.d and open CLI

    sudo nano 99-sysctl.conf
    net.ipv4.ip_unprivileged_port_start=0
    sudo sysctl --system

# Run the docker container
   
   docker-compose up

# Open new second commandline in different folder (while docker-compose up is running in the first command line!)

    docker ps
    #copy the container ID
    docker exec -it PASTETHECONTAINERID /bin/bash


#Create MYSQL database config (only works if logged into docker via docker exec ...)

    mysql -u root -p
    # enter password from .yml file MARIADB_PASSWORD or MARIADB_ROOT_PASSWORD)

#Create database and grant rights

    CREATE DATABASE put-database-name-here;
    USER put-username-here@localhost IDENTIFIED BY 'put-password-here';
    SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX, DROP, ALTER, CREATE TEMPORARY, TABLES, LOCK TABLES ON put-database-name-here.* TO 'put-username-here'@'localhost';


# still within mysql; Check which users are existing:

    select User, Host, Password from mysql.user;
    
    exit
    exit

#The container should now show up in "whaler" (https://github.com/whaler/whaler)
# Start the container again via "whaler" or use "docker-compose up" to run the container

   docker-compose up

# enter 127.0.0.1 in your webbrowser (e.g. Firefox)
    
    # Login via your username or alternatively via
      user: user
      password: bitnami


There were three major hurdles:

  1. persistent volumes for mariaDB and suitecrm should DIFFER. suitecrm config is created AFTER mariaDB and apparently checks if PATH/TO/PERSISTENCE is empty, before trying to create the config. If not empty, no config will be created. At least that's the hypothesis we have for why the php error was triggered.

  2. I was not able to access the standard port, because my docker is configured to not run as root, hence had to give privileges first.

  3. The mysql database was supposed to be created automatically during initial setup, but it was not, so we had to create it manually from scratch.

Greetings,

ThiloteE

@bitnami-bot bitnami-bot moved this from Pending to Triage in Support Mar 11, 2023
@carrodher carrodher moved this from Triage to Pending in Support Mar 13, 2023
@github-actions
Copy link

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

@github-actions github-actions bot added the stale 15 days without activity label Mar 27, 2023
@hlearr
Copy link

hlearr commented Mar 28, 2023

Same issue as @zoubinho, but hereafter the error during the creation of the database (with an ad-hoc volume for persistence):

suitecrm-suitecrm_mariadb-1  | mariadb 08:14:48.05 
suitecrm-suitecrm_mariadb-1  | mariadb 08:14:48.06 Welcome to the Bitnami mariadb container
suitecrm-suitecrm_mariadb-1  | mariadb 08:14:48.06 Subscribe to project updates by watching https://github.com/bitnami/containers
suitecrm-suitecrm_mariadb-1  | mariadb 08:14:48.06 Submit issues and feature requests at https://github.com/bitnami/containers/issues
suitecrm-suitecrm_mariadb-1  | mariadb 08:14:48.07 
suitecrm-suitecrm_mariadb-1  | mariadb 08:14:48.07 INFO  ==> ** Starting MariaDB setup **
suitecrm-suitecrm_mariadb-1  | mariadb 08:14:48.11 INFO  ==> Validating settings in MYSQL_*/MARIADB_* env vars
suitecrm-suitecrm_mariadb-1  | mariadb 08:14:48.13 INFO  ==> Initializing mariadb database
suitecrm-suitecrm_mariadb-1  | mkdir: cannot create directory '/bitnami/mariadb/data': Permission denied
suitecrm-suitecrm_mariadb-1 exited with code 1

What are the users and the permissions for the persistent volumes ?
Many thanks in advance

@bitnami-bot bitnami-bot moved this from Pending to Triage in Support Mar 28, 2023
@github-actions github-actions bot removed the stale 15 days without activity label Mar 29, 2023
@javsalgar javsalgar moved this from Triage to Pending in Support Mar 29, 2023
@jorgebosonit
Copy link

jorgebosonit commented Apr 12, 2023

I'm having the same issue with Suitecrm version 7

docker network create suitecrm-network
docker volume create --name debian-11_suitecrm_data3
docker volume create --name debian-11_mariadb_data3
docker run -d --name mariadb3 -p 3306:3306 --env MARIADB_USER=bn_suitecrm --env MARIADB_PASSWORD=bitnami123 --env MARIADB_DATABASE=bitnami_suitecrm --env MARIADB_ROOT_PASSWORD=bitnami --network suitecrm-network --volume debian-11_mariadb_data3:/bitnami/mariadb bitnami/mariadb:10.6

docker run -d --name suitecrm7 -p 8777:8080 -p 8447:8443 --env MARIADB_PORT_NUMBER=3306 --env SUITECRM_DATABASE_USER=bn_suitecrm --env SUITECRM_DATABASE_PASSWORD=bitnami123 --env SUITECRM_DATABASE_NAME=bitnami_suitecrm --network suitecrm-network --volume debian-11_suitecrm_data3:/bitnami/suitecrm  bitnami/suitecrm:7

The SuiteCRM server always stops working with this message: suitecrm 15:10:19.79 ERROR ==> Could not connect to the database

I've verified that both containers are in the same network, and even launching telnet from the SuiteCRM's container terminal it can access the Mariadb service.

@bitnami-bot bitnami-bot moved this from Pending to Triage in Support Apr 12, 2023
@carrodher carrodher moved this from Triage to Pending in Support Apr 13, 2023
@github-actions
Copy link

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

@github-actions github-actions bot added the stale 15 days without activity label Apr 29, 2023
@github-actions
Copy link

github-actions bot commented May 5, 2023

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.

@github-actions github-actions bot added the solved label May 5, 2023
@bitnami-bot bitnami-bot closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2023
@bitnami-bot bitnami-bot moved this from Pending to Solved in Support May 5, 2023
@github-actions github-actions bot removed this from Solved in Support May 8, 2023
@ralyodio
Copy link

ralyodio commented Jul 1, 2023

i'm also having this issue with default docker-compose file.

@bitnami-bot bitnami-bot added this to Triage in Support Jul 1, 2023
@github-actions github-actions bot removed the solved label Jul 1, 2023
@ThiloteE
Copy link

ThiloteE commented Jul 1, 2023

What are the users and the permissions for the persistent volumes ?

@hlearr, If I remember right (i am not sure though. It has been such a long time since I did it!), it would be the following step from my workaround:

#Create MYSQL database config (only works if logged into docker via docker exec ...)

mysql -u root -p
# enter password from .yml file MARIADB_PASSWORD or MARIADB_ROOT_PASSWORD)

@ThiloteE
Copy link

ThiloteE commented Jul 1, 2023

For everybody: I described a workaround in this comment. I think for this docker file to work flawlessly from the get go, it would need to be adapted the following way:

  1. the persistent volumes for mariaDB and suitecrm should DIFFER. because Suitecrm config is created AFTER mariaDB and apparently checks if PATH/TO/PERSISTENCE is empty, before trying to create the config. If not empty, no config will be created. At least that's the hypothesis we have for why the php error was triggered.

  2. The mysql database (feature of MariaDB) should be created automatically during initial setup. Currently it is not, so we have to create it manually from scratch. Btw. MariaDB is a fork of mysql, so don't be confused why it is called mysql instead of MariaDB.

@carrodher carrodher moved this from Triage to Solved in Support Jul 1, 2023
@github-actions github-actions bot added the solved label Jul 1, 2023
@github-actions github-actions bot removed this from Solved in Support Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solved stale 15 days without activity suitecrm tech-issues The user has a technical issue about an application triage Triage is needed
Projects
None yet
Development

No branches or pull requests

8 participants