How to run 2 flask apps and Nginx using a single docker-compose

I’m looking to run 2 flask containers and 1 Nginx container using one docker compose file but keep getting 404 errors.

Tried following a number of tutorials but still no luck.

Below is my docker compose file along with Nginx.conf and Uwsgi config.


version: "3.7"

        build: ./flask
        container_name: flask
        restart: always
        image: flask
            - APP_NAME=flask
            - 8080
            - "8080:8080"

        build: ./flask2
        container_name: flask2
        restart: always
        image: flask2
            - APP_NAME=flask2
            - 8081
            - "8081:8081"
        build: ./nginx
        image: nginx
        container_name: nginx
        restart: always
            - "80:80"
            - "81:81"
            - flask
            - flask2


upstream flask_app1 {
    server flask:8080;

upstream flask_app2 {
    server flask2:8081;

server {
    listen 80;

    location /test1 {
        uwsgi_pass flask_app1;

    location /test2 {
        uwsgi_pass flask_app2;

uwsgi: Both identical except port.

wsgi-file =
callable = app
socket = :8081
processes = 4
threads = 2
master = true
chmod-socket = 660
buffer-size = 32768
vacuum = true
die-on-term = true

I’m using docker for windows and I can see in the GUI that the 2 flask apps have ports binded at 8080 and 8081 and nginx being binded to port 80.

Not sure what the else the issue could be. Any help would be fantastic.

Thanks in advance.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

did you check firewall rules?

Hi there,

I’m having exaclty the same issue, went through many tutorials, but didn’t manage to have this configuration running.

Any help would be welcome.