Giter Site home page Giter Site logo

Comments (10)

LaurentGoderre avatar LaurentGoderre commented on May 26, 2024

I notice the absence of a port when creating the container. I believe that xdebug2 uses port 9000 while xdebug3 uses 9003 so you might need to export that port for the debugger to connect.

from php.

trymeouteh avatar trymeouteh commented on May 26, 2024

I notice the absence of a port when creating the container. I believe that xdebug2 uses port 9000 while xdebug3 uses 9003 so you might need to export that port for the debugger to connect.

When I add -p 9003:9003 to the container create command, it will cause port 9003 to be used, not allowing me to run the PHP debugger in VSCode which gives me the error that port 9003 is in use.

Is there another way to open a port but not use the port?

from php.

ssnepenthe avatar ssnepenthe commented on May 26, 2024

However this will force the container to use the host network

It shouldn't be necessary to set --network=host in order to use the host.containers.internal address.

from php.

trymeouteh avatar trymeouteh commented on May 26, 2024

However this will force the container to use the host network

It shouldn't be necessary to set --network=host in order to use the host.containers.internal address.

For me it is on Manjaro using the latest version of podman

from php.

ssnepenthe avatar ssnepenthe commented on May 26, 2024

Strange - it looks like this was added way back in podman 3.2 (https://github.com/containers/podman/releases/tag/v3.2.0)

Podman now adds an entry to /etc/hosts, host.containers.internal, pointing to the current gateway (which, for root containers, is usually a bridge interface on the host system) (containers/podman#5651).

I have used it for xdebug many times without setting --network=host - Maybe the manjaro package is doing something to disable this feature?

It should be easy to test, just check /etc/hosts in any container (containers/podman#10878 (comment)):

$ podman run docker.io/library/alpine grep host.containers.internal /etc/hosts
192.168.86.56	host.containers.internal host.docker.internal

Running podman 4.9.4 on fedora

from php.

trymeouteh avatar trymeouteh commented on May 26, 2024

This is what I get when I run these commands in the terminal...

$ podman run docker.io/library/alpine grep host.containers.internal /etc/hosts
10.0.2.15	host.containers.internal host.docker.internal
$ ifconfig
enp0s3:
        inet 10.0.2.15

$ podman --version
podman version 4.8.2

I wish I can try this on Debian :( but the latest version of Podman available for Debian based distros is 3.4.4

I did try to reproduce this on Fedora inside a VirtualBox VM, but I keep getting an SELinux popup when I run the container and the PHP script in the container which maybe preventing me from using the debugger. I never used Fedora before.

from php.

trymeouteh avatar trymeouteh commented on May 26, 2024

UPDATE:

I disabled SELinux in the Fedora VM by changing SELINUX=disabled in the /etc/selinux/config file. I was able to get the debugger to work with SELinux disabled, however I still needed to have --network=host as a flag when creating the container for VSCode debugging to work.

from php.

trymeouteh avatar trymeouteh commented on May 26, 2024

UPDATE:

When I create the container without using the --network=host flag but set xdebug.client_host setting in the php.ini to my device local IP address xdebug.client_host = 172.16.1.123, it will work. I do not know why it does not work when set to "host.containers.internal" or xdebug://gateway

Why is this the case?

from php.

ssnepenthe avatar ssnepenthe commented on May 26, 2024

What is the default network mode podman is using? If you omit the --network option entirely when you create your container and then run:

$ podman container inspect my-container | grep NetworkMode

What is the output?

from php.

trymeouteh avatar trymeouteh commented on May 26, 2024
$ podman container inspect my-container | grep NetworkMode
            "NetworkMode": "slirp4netns",

from php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.