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

FIX: PostgreSQL Connection Error #187

Merged
merged 1 commit into from
Jul 27, 2024

Conversation

beingsane
Copy link
Contributor

PostgreSQL Connection Error: Error using postgres database config in image docker.

FIX: PostgreSQL Connection Error
@beingsane
Copy link
Contributor Author

PostgreSQL Connection Error: Error using postgres database config in image docker.

@Llewellynvdm
Copy link
Member

Thank you, this is a long over due fix...

Yet, I would suggest one change.

Since the script's purpose is to create the database if it doesn't exist, the initial connection does not need to specify the dbname, especially if the database does not exist yet.

Can you test script to connect to the default postgres database (which is always present in a PostgreSQL installation) when checking for and creating the target database. Here's the corrected part of the script:

$connection = "host={$host} port={$port} user={$user} password={$password} dbname=postgres";

This is the docker-compose file I use to test this, with the dbname=postgres and it works well:

services:

  joomla:
    image: joomla:latest
    restart: always
    ports:
      - 8080:80
    environment:
      JOOMLA_DB_HOST: db
      JOOMLA_DB_USER: joomla
      JOOMLA_DB_PASSWORD: examplepass
      JOOMLA_DB_NAME: joomla_db
      JOOMLA_DB_TYPE: pgsql
      JOOMLA_SITE_NAME: Joomla
      JOOMLA_ADMIN_USER: Joomla Hero
      JOOMLA_ADMIN_USERNAME: joomla
      JOOMLA_ADMIN_PASSWORD: joomla@secured
      JOOMLA_ADMIN_EMAIL: [email protected]
    volumes:
      - joomla_data:/var/www/html
    networks:
      - joomla_network

  db:
    image: postgres:latest
    restart: always
    environment:
      POSTGRES_DB: joomla_db
      POSTGRES_USER: joomla
      POSTGRES_PASSWORD: examplepass
    volumes:
      - db_data:/var/lib/postgresql/data
    networks:
      - joomla_network

volumes:
  joomla_data:
  db_data:

networks:
  joomla_network:

@Llewellynvdm Llewellynvdm merged commit 73dbbce into joomla-docker:master Jul 27, 2024
25 of 26 checks passed
@beingsane
Copy link
Contributor Author

beingsane commented Aug 7, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants