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.
1version: "3"
2services:
3 php:
4 build:
5 context: .
6 ports:
7 - "80:80"
8 volumes:
9 - ./src:/var/local-src
10 mysql:
11 image: public.docker.itc.griffith.edu.au/mysql:8.0
12 container_name: mysql-server-80
13 command: --default-authentication-plugin=mysql_native_password
14 restart: always
15 environment:
16 - MYSQL_ROOT_PASSWORD=<password>
17 - MYSQL_DATABASE=<database>
18 - MYSQL_USER=<username>
19 - MYSQL_PASSWORD=<password2>
20 ports:
21 - "3306:3306"
1{
2 "host": "host.docker.internal",
3 "port": 3306,
4 "user": "<username>",
5 "password": "<password>",
6 "db": "<database>"
7}