Describe the bug
Connecting Prisma to a local MySQL docker container on a different port than 3306 crashes Prisma.
To Reproduce
Steps to reproduce the behavior:
npm install prisma@betaprisma init abc -> follow wizard to create new docker-compose.yml for local MySQLcd abcdocker-compose.yml withversion: '3'
services:
prisma:
image: prismagraphql/prisma:1.17-beta
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
# managementApiSecret: my-secret
databases:
default:
connector: mysql
host: mysql
port: 3307
user: root
password: prisma
migrations: true
rawAccess: true
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: prisma
ports:
+ - "3307:3306"
volumes:
- mysql:/var/lib/mysql
volumes:
mysql:
docker-compose up -ddocker ps and check the status of the prisma container - it'll restart every ~10 seconds and crash:
Expected behavior
Prisma connects to the MySQL container on port 3307.
Versions (please complete the following information):
prisma CLI: prisma/1.17.0-beta.24 (darwin-x64) node-v10.8.01.17-betaI looked into this and concluded that this is not a bug but a misunderstanding about docker-compose. I also misunderstood it and just realised after a few minutes as it is easy to fall for this.
The important thing is this port mapping of the mysql container:
ports:
- "3307:3306"
This line maps the container port 3306 to the port 3307 on the host system. That means one can reach the mysql instance on this port when using something like a GUI. However this does not change the port of the mysql container inside the docker network. The prisma instance must still use the port 3306 the MySQL container is exposing.
In order to get it to work one would have to start the MySQL server with a different port in the first place. Usually popular Docker images expose environment variables to do so but i could not find them for MySQL. Instead It seems like MySQL can only be configured through config files that are a lot more cumbersome in conjunction with Docker.
TLDR: It's not a bug. This configuration does not run MySQL on port 3307 inside the docker network and therefore it does not work.
Most helpful comment
I looked into this and concluded that this is not a bug but a misunderstanding about
docker-compose. I also misunderstood it and just realised after a few minutes as it is easy to fall for this.The important thing is this port mapping of the mysql container:
This line maps the container port 3306 to the port 3307 on the host system. That means one can reach the mysql instance on this port when using something like a GUI. However this does not change the port of the mysql container inside the docker network. The prisma instance must still use the port 3306 the MySQL container is exposing.
In order to get it to work one would have to start the MySQL server with a different port in the first place. Usually popular Docker images expose environment variables to do so but i could not find them for MySQL. Instead It seems like MySQL can only be configured through config files that are a lot more cumbersome in conjunction with Docker.
TLDR: It's not a bug. This configuration does not run MySQL on port 3307 inside the docker network and therefore it does not work.