進(jìn)行步驟:
1.先安裝帶xdebug擴(kuò)展的php容器,我創(chuàng)建php容器的Dockerfile
2.其中php.ini的配置為下,更多配置信息查看官方手冊:
xdebug.remote_enable=1
xdebug.remote_connect_back = 1 // 當(dāng)該項(xiàng)啟動時(shí)remote_host配置無效
;xdebug.remote_host=192.168.3.5
xdebug.remote_port=9007 // 宿主監(jiān)聽端口
xdebug.remote_handler="dbgp"
xdebug.max_nesting_level = 5000
xdebug.remote_autostart = 1
xdebug.remote_log="/tmp/xdebug.log" // xdebug遠(yuǎn)程連接日志
3.確定本地文件路徑和docker容器中的文件路徑是否一致,這個(gè)問題煩了我兩三周,一直找不到解決方案,下方為我的debug過程:
在容器內(nèi)安裝ngrep查看端口數(shù)據(jù)傳輸問題

數(shù)據(jù)傳輸抓取
由此可看出,docker容器是ip為172.18.0.2端口為58614像宿主機(jī)器192.168.3.5的9007端口傳輸數(shù)據(jù),對應(yīng)的文件路徑為/usr/local/nginx/html/laravel5.5/public/index.php(此為宿主文件路徑),