Docker4drupal: Access mysql on host

Created on 13 Jan 2017  路  6Comments  路  Source: wodby/docker4drupal

Hi. Is it possible for my drupal running on the containers to access a second mysql database on the host?

help wanted

All 6 comments

I think so. On port 8001 you can access the phpmyadmin interface and there you can create a second database

@parijke i am not sure you understood my question. Thank you though!

I have a mac with a native MYSQL server running.
On this mac i have docker4drupal running.
I have a drupal instance running on the respective container of docker4drupal.
I need this instance to connect to the host's (mac) MYSQL server.

@dcre the easiest way is to migrate db into the second docker container of mariadb in docker-compose environment.

Ok this is a closed topic but I think the original answer sought was never got. I found it here:
https://stackoverflow.com/a/43011927/742755
Add to the mysql definition in docker-compose.yml, or docker-compose.override.yml as in my example here, a mapping of local port to docker-mysql port:

  mysql:
    environment:
      MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
    ports:
      - 33306:3306

With the above in your docker-compose.override.yml, rerun docker-compose up. You will now be able to connect to your wodby docker4drupal mysql/mariadb instance with something like:

mysql -udrupal -pdrupal drupal -P33306 -h127.0.0.1
in your local terminal or similar values in Sequel Pro, etc.

I included environment and the password bit not because it is required for this (it is not), but because I wanted to demonstrate both how docker-compose.override.yml selectively merges and overrides specific values and where to nest ports to make the magic.

hth
-Bronius

Actually, on macOS you can use host.docker.internal to access host network

Actually, on macOS you can use host.docker.internal to access host network

Well.. I am using host.docker.internal for php debugging, and I do have PHP_XDEBUG_REMOTE_HOST: host.docker.internal in my docker-compose.yml, but I could never get anything else I tried to work.. 馃し鈥嶁檪 This above works for me..

Was this page helpful?
0 / 5 - 0 ratings

Related issues

magick93 picture magick93  路  7Comments

rsanzante picture rsanzante  路  7Comments

pulasthibandara picture pulasthibandara  路  6Comments

quietone1 picture quietone1  路  10Comments

jzavrl picture jzavrl  路  3Comments