I have a Node.js app (using the new NestJS) framework, running on port 3000. As the database I use MySQL via TypeORM. Locally it all works fine. I am having problems dockerizing it though.
My TypeORM config:
{
"type": "mysql",
"host": "localhost",
"port": 3306,
"username": "root",
"password": "root",
"database": "nest",
"entities": ["src/**/*.entity{.ts,.js}"],
"synchronize": true
}
My docker-compose.yml is as follows:
version: "3"
services:
db:
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: nest
MYSQL_USER: root
MYSQL_PASSWORD: root
networks:
- new
nest:
image: grimscythe/nest-sample
depends_on:
- db
ports:
- 3000:3000
networks:
- new
networks:
new:
I've been reading the docs on this particular scenario and all should work just fine.
Bash'ing into the MySQL container shows that the DB is running just fine. However the Node framework spits Unable to connect to the database.... Am I missing something in the docker-compose.yml file?