jonnie jonnie - 1 year ago 156
PHP Question

How can I debug php mounted to a container running on docker beta for mac

I have spent half the day trying different things including this solution I came across on

I have a docker-compose file which mounts a folder containing my client and server projects:

- ~/projectx:/projectx

my docker php.ini contains the following xdebug options

xdebug.var_display_max_children = 999
xdebug.var_display_max_data = 999
xdebug.var_display_max_depth = 100

I have the xdebug chrome extension installed

In my mac host file I have the following localhost
so I can access my web app (and other docker web apps) through
which all works to run the app

In Phpstorm (version 2016.1.2) In preferences
Languages & Frameworks
Servers I have :

host =, port=80 , Debugger = Xdebug
Use path mappings is checked and I have

      File/Directory set to

      Absolute path on the server is set to

I have tried setting the
to my macs ip obtained from ifconfig as well as trying the ip in

But I cannot hit a breakpoint , I have even added
double check.
I am also running the latest docker beta
Version 1.12.0-rc3-beta18 (build: 9996)

I would very much appreciate anyone's help, it's a real blocker for me.

If any further information is required I am happy to provide.

Answer Source

The workaround I used was to open up an ssh tunnel to the docker container running php using a command like, in my case I have the docker container ssh port mapped to 12 hence the -p 12

ssh -R 9000:localhost:9000 -p:12

UPDATE: The Correct way

so I eventually figured out that my xdebug settings in docker should be

xdebug.remote_enable = 1

where is the entry found in ~/Library/Containers/com.docker.docker/Data/database/com.docker.driver.amd64-linux/slirp/host

Also make sure to set the idekey correctly in the chrome extension, in my case PHPSTORM
With this I no longer require the ssh tunnel

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download