WILT: MySQL as a separate service in a PHP app container
Another quick one. Was struggling to get a mysql service up and running alongside a PHP container for a quick migrate/ translate thing. Way to do this is to use the docker host host.docker.internal
as the MySql host to access.
version: "3"
services:
php:
build:
context: .
ports:
- "80:80"
volumes:
- ./src:/var/local-src
mysql:
image: public.docker.itc.griffith.edu.au/mysql:8.0
container_name: mysql-server-80
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
- MYSQL_ROOT_PASSWORD=<password>
- MYSQL_DATABASE=<database>
- MYSQL_USER=<username>
- MYSQL_PASSWORD=<password2>
ports:
- "3306:3306"
{
"host": "host.docker.internal",
"port": 3306,
"user": "<username>",
"password": "<password>",
"db": "<database>"
}