How to setup flask-socketio in a docker container? How to setup flask-socketio in a docker container? flask flask

How to setup flask-socketio in a docker container?


When starting compose, make sure all environment variable are set for flask. Also provide the --host=0.0.0.0 to listen on all network interfaces, in your entrypoint or command.

The updated docker-compose file:

version: "3"services:    web:        build: ./web        volumes:            - './application:/application'        environment:            FLASK_DEBUG: 1            FLASK_ENV: development            FLASK_APP: web_app.py        ports:            - '5000:5000'        entrypoint:            - flask            - run            - --host=0.0.0.0

When you want to run the container in interactive mode for development purposes, you could run it with docker-compose run the below command. --service-ports is required to expose the containers ports as specified in the compose file. If this flag isn't provided, no external traffic will reach the app. That was my original problem.

docker-compose run --service-ports web bash

Alternatively you could publish the port manually

docker-compose run --publish 5000:5000 web bash


You haven't started app in your docker container. Add two more lines to the Dockerfile:

EXPOSE 5000ENTRYPOINT ["python", "/code/web_app.py"]