Home > Mobile >  docker compose network not serving reqeusts from host
docker compose network not serving reqeusts from host

Time:10-28

[docker-compose question]

hello all! I've been stuck on this for a while so hopefully we can debug together.

I'm using docker compose to bring up three separate services. Everything builds and comes up great. Health check for the app passes, the services make contact with each other but I can't seem to my curl my app from the host.

I've tried the following values for app.ports:

"127.0.0.1:3000:3000" "3000:3000" "0.0.0.0:3000:3000"

I've also tried to run this with a "host" network, but that also didn't seem to work and I don't prefer it because apparently that is not supported on Mac and my local developer environment is Macosx. The prod server is ubuntu.

And I've tried defining the default bridge netowrk explicitly:

networks:
    default:
        driver: bridge

Here is my docker-compose.yml

version: "2.4"
services:
    rabbitmq:
        image: rabbitmq
        volumes:
            - ${ML_FILE_PATH}/taskqueue/config/:/etc/rabbitmq/
        environment:
            LC_ALL: "C.UTF-8"
            LANG: "C.UTF-8"
    celery-worker:
        image: ${ML_IMAGE_NAME}
        entrypoint: "celery --broker='amqp://<user>:<password>@rabbitmq:5672//' -A taskqueue.celeryapp worker --uid 1111"
        runtime: ${RUNTIME}  ## either "runc" if running locally on debug mode or "nvidia" on production with multi processors
        volumes:
            - ${ML_FILE_PATH}:/host
        depends_on:
            - rabbitmq
            - app
        environment:
            LC_ALL: "C.UTF-8"
            LANG: "C.UTF-8"
            MPLCONFIGDIR: /host/tmp
        volumes:
            - ${ML_FILE_PATH}:/host
    celery-beat:
        image: ${ML_IMAGE_NAME}
        entrypoint: "celery --broker='amqp://<user>:<password>@rabbitmq:5672//' -A taskqueue.celeryapp beat --uid 1111"
        runtime: ${RUNTIME}  ## either "runc" if running locally on debug mode or "nvidia" on production with multi processors
        depends_on:
            - rabbitmq
            - app
        environment:
            LC_ALL: "C.UTF-8"
            LANG: "C.UTF-8"
            MPLCONFIGDIR: /host/tmp
        volumes:
            - ${ML_FILE_PATH}:/host
    app:
        build: .
        entrypoint: ${ML_ENTRYPOINT}  # just starts a flask app
        image: ${ML_IMAGE_NAME}
        ports:
            - "3000:3000"
        expose:
            - "3000"
        volumes:
            - ${ML_FILE_PATH}:/host
        restart: always
        runtime: ${RUNTIME}
        healthcheck:
            test: ["CMD", "curl", "http:/localhost:3000/?requestType=health-check"]
            start_period: 30s
            interval: 30s
            timeout: 5s
        environment:
            SCHEDULER: "off"
            TZ: "UTC"
            LC_ALL: "C.UTF-8"
            LANG: "C.UTF-8"

I can hit the service from within the container as expected.

I'm not sure what I'm missing. Thanks so much for any help!

CodePudding user response:

I'm not sure but i think you dont can route traffic from the host to containers on mac osx.

https://docs.docker.com/desktop/mac/networking/

CodePudding user response:

This ended up being mostly unrelated to docker-compose.

My flask app was starting up on 127.0.0.1. I needed to be starting it as an externally visible server.

I just had to add --host=0.0.0.0 to my start script.

  • Related