Docker shared network with multiple nginx instances, gives random nginx instance

I am setting up the following docker containers with the following 2 docker-compose files:

version:  '3.7'
services:
    mysql:
        image: mysql:5.7
        restart: on-failure
        environment:
            MYSQL_DATABASE: ${MYSQL_DATABASE}
            MYSQL_USER: ${MYSQL_USER}
            MYSQL_PASSWORD: ${MYSQL_PASSWORD}
            MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
        volumes:
            - db_data:/var/lib/mysql:rw
        ports:
            - '${MYSQL_PORT}:3306'
        networks:
            - shared_mysql
    php:
        build:
            context: .
            dockerfile: docker/php/Dockerfile
        restart: on-failure
        volumes:
            - '../:/usr/src/app'
        user: ${LOCAL_USER}
        networks:
            - shared_mysql
    api_nginx:
        image: nginx:1.15.3-alpine
        restart: on-failure
        volumes:
            - '../public/:/usr/src/app'
            - './docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro'
        ports:
            - '21180:80'
        depends_on:
            - php
        networks:
            - shared_mysql
    phpmyadmin:
        image: phpmyadmin/phpmyadmin
        restart: on-failure
        ports:
            - '${PHPMYADMIN_PORT}:80'
        environment:
            PMA_HOST: mysql
            MYSQL_USERNAME: ${MYSQL_USER}
            MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}
        networks:
            - shared_mysql

volumes:
    db_data:

networks:
    shared_mysql:
version:  '3.7'
services:
    php:
        build:
            context: .
            dockerfile: docker/php/Dockerfile
        restart: on-failure
        volumes:
            - '../:/usr/src/app'
        user: ${LOCAL_USER}
        networks:
            - api_21s_shared_mysql
    auth_nginx:
        image: nginx:1.15.3-alpine
        restart: on-failure
        volumes:
            - '../public/:/usr/src/app'
            - './docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro'
        ports:
            - '21181:80'
        depends_on:
            - php
        networks:
            - api_21s_shared_mysql

volumes:
    db_data:

networks:
    api_21s_shared_mysql:
        external: true

When I visit http://localhost:21181/, I always get the correct website.

But when I visit http://localhost:21182/, I get http://localhost:21181/ or http://localhost:21182/ random.

I tried to set up the network sepperate.

I’d like it to work with the portnumbers, but I don’t want them to be mixed up.

I am hoping someone can help me. Thank you in advance.

Source: StackOverflow