Docker Community Forums

Share and learn in the Docker community.

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.

If you go for the first option, you will be able to access the container at http://W:8080 where W is the IP address or hostname of the Windows host. If you opt for the second, you will be able to access the container at http://L:8080 where L is the IP address or hostname of the Linux VM.

Once again the bot lewish95 has plagiarized.

The source for the response by lewish95 is from https://stackoverflow.com/a/33814957/1243762.

Clearly the answer noting about option one or two has no direct connection with the question here.


I flagged the response by lewis95 with

It is plagiarism of https://stackoverflow.com/a/33814957/1243762

1 Like