i followed docker compose tutorial
https://docs.docker.com/get-started/08_using_compose/
to create composer file for todo app with mysql service
- i did the same docker compose as the tutorial
but it gave me this error
app-mysql-1 | 2022-05-28T21:55:26.950553Z 3 [Note] Unknown database 'todos'
app-app-1 | Error: ER_BAD_DB_ERROR: Unknown database 'todos'
- i executed mysql container services to see if todos database created or not
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
docker compose
version: "3.7"
services:
app:
image: node:12-alpine
command: sh -c "yarn install && yarn run dev"
ports:
- 3000:3000
working_dir: /app
volumes:
- ./:/app
environment:
MYSQL_HOST: mysql
MYSQL_USER: root
MYSQL_PASSWORD: secret
MYSQL_DB: todos
mysql:
image: mysql:5.7
volumes:
- todo-mysql-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: todos
volumes:
todo-mysql-data:
2
Answers
Thanks Hambrook i found that there was a volume with the same name i tried to create
so i removed it and write command again
and it's work
Running just the mysql portion of your docker-compose file seems to have worked for me.
You might want to try deleting the volume and recreating your containers.
docker volume rm todo-mysql-data
docker-compose up --force-recreate