Answer the question
In order to leave comments, you need to log in
How to connect Python to MySQL in Docker?
version: '3.3'
services:
mysql:
image: mysql:8.0
container_name: Mysql8
restart: unless-stopped
volumes:
- ./docker/mysql/data:/var/lib/mysql
networks:
- app
environment:
...
ports:
- 3306:3306
api:
image: ...
container_name: API
depends_on:
- mysql
restart: unless-stopped
environment:
- DB_HOST=Mysql8:3306
...
networks:
- app
ports:
- 3002:3002
bot:
image: ...
container_name: Bot
restart: unless-stopped
depends_on:
- mysql
environment:
- DB_HOST=Mysql8:3306
...
networks:
- app
ports:
- 3006:3006
networks:
app:
driver: bridge
Answer the question
In order to leave comments, you need to log in
He could not sober up the name Mysql8. Check if it fits /etc/hosts
in the container.
I think it should help:
docker-compose down
docker-compose up -d
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question