I have a simple Flask app consisting of a web part and a database part. Code can be found here. Running this Flask app locally works perfectly well.
I'd like to have the app run on Docker. Therefore I created the following docker-compose file.
version: '3.6'
services:
web:
build: .
depends_on:
- db
networks:
- default
ports:
- 50000:5000
volumes:
- ./app:/usr/src/app/app
- ./migrations:/usr/src/app/migrations
restart: always
db:
environment:
MYSQL_ROOT_PASSWORD: ***
MYSQL_DATABASE: flask_employees
MYSQL_USER: root
MYSQL_PASSWORD: ***
image: mariadb:latest
networks:
- default
ports:
- 33060:3306
restart: always
volumes:
- db_data:/var/lib/mysql
volumes:
db_data: {}
Inside the Flask app, I'm setting the following SQLALCHEMY_DATABASE_URI = 'mysql://root:***@localhost:33060/flask_employees'
.
When I do docker-compose up
, both containers are created and are running however when I go to http://localhost:50000 or http://127.0.0.1:50000 I get:
This site can’t be reached, 127.0.0.1 refused to connect.