I've been having an issue with Docker on Ubuntu for a few days now. I've already read through various stackoverflow and Reddit posts, but unfortunately haven't found a suitable answer.Here's what I'm trying to do: I have a Docker PHP container that I'd like to debug on the host using VS Code with XDEBUG.I've installed the Docker Engine from Docker's apt repository on Ubuntu (Docker Desktop isn't an option). The configuration in the docker-compose.yaml file looks like this:
php: ports: - 8080:80 extra_hosts: - "host.docker.internal:host-gateway" environment: XDEBUG_CONFIG: client_host=host.docker.internal client_port=9003 start_with_request=yes discover_client_host=true remote_connect_back=1 idekey=VSCODE
In VS Code, I've installed the PHP Debug extension and set up a launch.json with the same port.The issue is that "ping host.docker.internal" (within the container) works fine. However, "nc -vz host.docker.internal 9003" always returns connection refused, which is why XDEBUG can't connect to VS Code. On the Ubuntu host itself, I've actually disabled the ufw firewall, but I also enabled it for testing purposes and allowed port 9003. Additionally, I've compared "/etc/hosts" on both the host machine and the container with responses from other forums, but everything seems to be correct.Unfortunately, I've run out of ideas on how to solve this problem.
Does anyone happen to have a similar setup and has already solved this issue? I would greatly appreciate any help!