docker-joomla icon indicating copy to clipboard operation
docker-joomla copied to clipboard

Joomla defaults to local ip address for external database

Open raceboyer opened this issue 8 years ago • 4 comments

Guys,

I have built joomla with my own modules and it builds fine:

Dockerfile.txt

I am able to run it locally and connect to a remote database with the environmental variables set in the image.

however, when I save it and move it to another docker host and then try to run it with the same commands or docker-compose.yml it tries to connect on the local ip of the host that I try to run it on.

I have tried using this docker-compose.yml

joomla:
  image: pc2joomla:v1.0
  ports:
    - 8080:80
  environment:
    - JOOMLA_DB_HOST=10.55.9.198
    - JOOMLA_DB_USER=user
    - JOOMLA_DB_PASSWORD=password
    - JOOMLA_DB_NAME=db

build system: Docker version 1.13.0, build 78d1802

host system: Docker version 1.8.2-el7, build a01dc02/1.8.2

I've tried it on 3 different hosts and it always ignores the environmental variables pointing to the external database whether they are set on the command line, through the docker-compose file.

if I run: docker run --name hcp2 -p 8080:80 -e JOOMLA_DB_HOST=10.55.9.198:3306 -e JOOMLA_DB_PASSWORD=password pc2joomla:v1.0

I get this error:

Joomla not found in /var/www/html - copying now... Complete! Joomla has been successfully copied to /var/www/html Ensuring Joomla database is present Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'hcp2'@'10.8.55.26' (using password: YES) in /makedb.php on line 20 MySQL Connection Error: (1045) Access denied for user 'hcp2'@'10.8.55.26' (using password: YES) Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'hcp2'@'10.8.55.26' (using password: YES) in /makedb.php on line 20

until it times out. Any ideas as to why this is happening?

raceboyer avatar Apr 26 '17 20:04 raceboyer

Can't say I have a clue at first glance. It all looks configured correctly.

mbabker avatar May 01 '17 11:05 mbabker

Ok, no worries. I appreciate you looking at it!

raceboyer avatar May 01 '17 19:05 raceboyer

You should check the privileges of the MySQL user. Login needs to be allowed from the containers IP (assuming that all other login data is correct).

J0WI avatar Jan 30 '18 18:01 J0WI

I had the same error message. I suspect it is because the joomla container has no route to 10.55.9.198, the database host. The error message is consistent with this problem.

I eventually resolved my error by configuring an appropriate Docker network. See https://docs.docker.com/network/

cherdt avatar Oct 22 '19 05:10 cherdt

I would say that this is a external issue, and not directly related to the Joomla Images.

I use the well-known Traefik egress router and with a basic setup like this:

version: '2'
services:
  mariadb_test:
    image: mariadb:latest
    container_name: mariadb_test
    restart: unless-stopped
    environment:
      - MARIADB_DATABASE=${VDM_TEST_DB}
      - MARIADB_USER=${VDM_TEST_DB_USER}
      - MARIADB_PASSWORD=${VDM_TEST_DB_PASS}
      - MARIADB_ROOT_PASSWORD=${VDM_TEST_DB_ROOT}
    volumes:
      - "${VDM_PROJECT_PATH}/test/db:/var/lib/mysql"
    networks:
      - traefik
  joomla_test:
    image: joomla:4
    container_name: joomla_test
    restart: unless-stopped
    environment:
      - APACHE_RUN_USER=#1000
      - APACHE_RUN_GROUP=#1000
      - JOOMLA_DB_HOST=mariadb_test:3306
      - JOOMLA_DB_NAME=${VDM_TEST_DB}
      - JOOMLA_DB_USER=${VDM_TEST_DB_USER}
      - JOOMLA_DB_PASSWORD=${VDM_TEST_DB_PASS}
    depends_on:
      - mariadb_test
    volumes:
      # make our website files persistent
      - "${VDM_PROJECT_PATH}/test/joomla:/var/www/html"
      # add our own php values
      - "${VDM_PROJECT_PATH}/test/php.ini:/var/www/html/php.ini"
      # add our own entry point
      - "${VDM_PROJECT_PATH}/test/docker-entrypoint.sh:/entrypoint.sh"
      # set our own website apache config
      - "${VDM_PROJECT_PATH}/test/000-default.conf:/etc/apache2/sites-enabled/000-default.conf"
    networks:
      - traefik
    labels:
      # joomla
      - "traefik.enable=true"
      - "traefik.http.routers.joomla_test.rule=Host(`test.builder.com`)"
#      - "traefik.http.routers.joomla_test.entrypoints=web"
#      - "traefik.http.routers.joomla_test.tls.certresolver=comresolver"
#      - "traefik.http.routers.joomla_test.service=joomla_test"
#      - "traefik.http.services.joomla_test.loadbalancer.server.port=80"
  phpmyadmin_test:
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin_test
    restart: unless-stopped
    environment:
      PMA_HOST: mariadb_test
      PMA_PORT: 3306
      UPLOAD_LIMIT: 300M
    depends_on:
      - mariadb_test
    networks:
      - traefik
    labels:
      # phpmyadmin
      - "traefik.enable=true"
      - "traefik.http.routers.phpmyadmin_test.rule=Host(`database.builder.com`)"
#      - "traefik.http.routers.phpmyadmin_test.entrypoints=web"
#      - "traefik.http.routers.phpmyadmin_test.tls.certresolver=comresolver"
#      - "traefik.http.routers.phpmyadmin_test.service=phpmyadmin_test"
#      - "traefik.http.services.phpmyadmin_test.loadbalancer.server.port=80"

networks:
  traefik:
    external:
      name: traefik_webgateway

I never have any issues. TO test this more, and to have an easy to use Joomla Docker deployment tool check out OctoJoom. You will see that this tool manages all this for you and helps writing you docker-composer files for you.

Should you have any further question on this please do not hesitate to open a new issue with the relevant details.

Llewellynvdm avatar Sep 10 '22 13:09 Llewellynvdm