Let container communicate with a specific port oustide of Docker

Hey,

so i’m currently facing the problem, that I’m not able to talk to a specific port, which is outside of my docker setup. To be exact:

As you can see in the docker-compose.yml down below, i’m running nginx and php in my docker setup. I’m trying to work with a PHP framework right now, which needs to talk to a server on port 10011 which runs as a local server on my pc. In this case, it’s an teamspeak-server, but this shouldn’t make any difference to the topic itself.

When I try to connect to this server via my php docker container, I get an 111 - Connection refused error. When I run the exact same code via XAMPP, everything works just fine. So there seems to be something wrong with my docker setup.

My docker-compose file:

version: "3.2"
services:

  php:
    build:
      context: './.docker/php/'
      args:
        PHP_VERSION: ${PHP_VERSION}
    networks:
      - backend
    volumes:
      - ${PROJECT_ROOT}/:/var/www/html/
    container_name: php

  apache:
    build:
      context: './.docker/apache/'
    depends_on:
      - php
      - db
    networks:
      - frontend
      - backend
    ports:
      - "80:80"
    volumes:
      - ${PROJECT_ROOT}/:/var/www/html/
    container_name: apache

networks:
  frontend:
  backend:
volumes:
  data:

Note: All unrelated containers were removed for brevity.

How can I fix this? And what do I need to change, when the teamspeak server wouldn’t run locally, but on a completely own server?

Thank you for reading.