Reddit – Dive into anything

Hi,

so I have a python script doing some GET requests and a database. I wanted to set up a docker compose with two services: My python app and the database.

I run into a problem doing get requests from inside the container. I don’t have the problem if I run the python app in a container spun up using

docker run --rm -d --network host --name myapp myapp

but it doesn’t work if I do:

services:
    scraper:
        build: .
        networks:
          - app-tier
        volumes:
          # Bind dev dir
          - type: bind
            source: .
            target: /code
        hostname: myhost

    mongo:
        image: mongo
        restart: always
        environment:
            MONGO_INITDB_ROOT_USERNAME: root
            MONGO_INITDB_ROOT_PASSWORD: password
        networks:
           - app-tier

networks:
    app-tier:
        driver: host

Where’s the difference?