Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 800 forks source link

Make Docker mysql container more accessible to the host #16483

Open mdrovdahl opened 4 years ago

mdrovdahl commented 4 years ago

Is your feature request related to a problem? Please describe.

After installing the Jetpack Docker based development environment, I can't connect to the mysql container. The docs here https://github.com/Automattic/jetpack/tree/master/docker#mysql-database suggest it should be possible, however I couldn't figure out how to do it.

Describe the solution you'd like

I'd like to be able to connect to the mysql container from the host (macOS in my case) using the mysql client. To do so, the jetpack_mysql container needs to forward a port. I'm no Docker expert, but I was able to make this work by adding the below to the services > db section of the docker-compose.yml:

    ports:
      - "${PORT_DB:-3306}:3306"

After brining docker down and back up, I can now connect via:

mysql -h 127.0.0.1 -P 3306 --user="wordpress" --password="wordpress"

kraftbj commented 3 years ago

In addition to opening the port, you can access mysql via cli by using the yarn docker:db command. The PR to expose the port would help if you have any other DB management tools you'd like to use.