Variabel SQL_INTERNAL_PORT
har förmodligen 3307
värde. Du måste ändra den till 3306
.
Du kan också ta bort
expose:
- "${SQL_INTERNAL_PORT}"
rader. Mysql exponerar redan 3306-porten.
Alla applikationer i klustret använder interna portar (3306 i mysql-fallet). Externa portar (i sektionsportar) behöver du endast för extern ordkommunikation.
Om du vill ha flera databaser måste du ändra docker-compose något så här:
version: '3'
services:
hackernews:
image: prismagraphql/prisma:1.8
restart: always
ports:
- "${CLIENT_PORT}:${INTERNAL_PORT}"
environment:
PRISMA_CONFIG: |
port: $INTERNAL_PORT
managementApiSecret: $PRISMA_MANAGEMENT_API_SECRET
databases:
default:
connector: mysql
host: mysql_first
port: 3306
user: root
password: $SQL_PASSWORD
migrations: true
second:
connector: mysql
host: mysql_second
port: 3306
user: root
password: $SQL_PASSWORD
migrations: true
mysql_first:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: $SQL_PASSWORD
ports:
- 3307:3306
volumes:
- ./custom/:/etc/mysql/conf.d/my.cnf
- mysql:/var/lib/mysql
mysql_second:
image: mysql:5.7
restart: always
environment:
ports:
- 3308:3306
MYSQL_ROOT_PASSWORD: $SQL_PASSWORD