Skip to content

Instantly share code, notes, and snippets.

@vranac vranac/README.md Secret
Last active Nov 16, 2018

Embed
What would you like to do?

When the docker moved to the new engine, one of the things to go is docker0 network interface. To quote the docs on networking

I want to connect from a container to a service on the host The Mac has a changing IP address (or none if you have no network access). Our current recommendation is to attach an unused IP to the lo0 interface on the Mac; for example: sudo ifconfig lo0 alias 10.200.10.1/24, and make sure that your service is listening on this address or 0.0.0.0 (ie not 127.0.0.1). Then containers can connect to this address.

What this essentially mean is that you don't have a network address to target with xdebug.

But there is a workaround... You can either execute the following in your terminal to create a loopback interface alias to an ip address

sudo ifconfig lo0 alias 10.254.254.254 255.255.255.0

You would, of course, have to reexecute it on restarts, as this is not a permanent solution.

Or if you want a more permanent solution, you can copy the com.docker_alias.plist file from config/osx-config to /Library/LaunchDaemons/com.docker_alias.plist and from then on, on every reboot the loopback will be setup.

To verify that everything has been setup properly, execute ifconfig from terminal and the output should look along the lines of this

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
	options=3<RXCSUM,TXCSUM>
	inet6 ::1 prefixlen 128
	inet 127.0.0.1 netmask 0xff000000
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
	inet 10.254.254.254 netmask 0xff000000  <--- here you can see it has been setup properly
	nd6 options=1<PERFORMNUD>

If you want to use a different ip, go ahead, but make a note of it, and put it into your .env for HOST_IP key. The plist file is based on this gist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.docker_alias.plist</string>
<key>ProgramArguments</key>
<array>
<string>ifconfig</string>
<string>lo0</string>
<string>alias</string>
<string>10.254.254.254</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
; configuration for php xdebug module
; priority=20
;zend_extension=xdebug.so
xdebug.max_nesting_level = 1000
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.remote_autostart=1
xdebug.remote_host=10.254.254.254
xdebug.idekey=docker-xdebug
xdebug.remote_port=9000
xdebug.remote_log=/var/log/xdebug/xdebug.log
xdebug.var_display_max_depth=3
xdebug.var_display_max_data=-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.