localhost development - how to fetch data from a different localhost port

My docker setup is very simple

version: '3.7'
services:

    php:
        build: ./docker/php
        ports: ['9000:9001']
        volumes:
            - ./symfony/:/var/www/symfony:cached

    nginx:
        build: docker/nginx
        restart: unless-stopped
        ports:
            - "7000:80"
        volumes:
            - ./docker/var/nginx:/var/log/nginx:cached
            - ./symfony/:/var/www/symfony:cached

So http://localhost:7000 is my route for development. Here with php I try to fetch the api from another local docker installation with Port 8000 (or Port 80).

$result = file_get_contents('http://localhost:8000');
$result = file_get_contents('http://localhost');
-> Warning: ... failed to open stream: Address not available

but a real url works fine

$result = file_get_contents('https://www.google.de')

I do not understand what’s going on. I would be very happy about any help.