Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run php-xdebug in docker(WSL2) #6993

Closed
slps970093 opened this issue Jun 1, 2020 · 5 comments
Closed

Can't run php-xdebug in docker(WSL2) #6993

slps970093 opened this issue Jun 1, 2020 · 5 comments

Comments

@slps970093
Copy link

I tried to set up a PHP development environment in Docker in WSL 2 mode, and it does not work with Xdebug

@stephen-turner
Copy link
Contributor

Could you please supply more details of what you did, what you expected, the symptoms, and include a diagnostics id. Thank you.

@slps970093
Copy link
Author

I execute docker-compose
The yml format is as follows

version: '2.0'

services:
  buylive_redis:
    container_name: buylive_redis
    image: redis:5
    ports:
      - 6379:6379
    networks:
      - buylive_network
    volumes:
      - D:\dockerToolbox\share\php\buylive\docker_compose\dev\php74\redis.conf:/usr/local/etc/redis/redis.conf
    command: [ "redis-server", "/usr/local/etc/redis/redis.conf" ]
  buylive:
    build:
      context: images
      dockerfile: Dockerfile
    container_name: "buylive_dev_web"
    volumes:
      - D:\dockerToolbox\share\php\buylive\:/var/www/html
      - D:\dockerToolbox\share\php\buylive\docker_compose\dev\php74\php.ini:/usr/local/etc/php/php.ini
    ports:
      - 80:80
    depends_on:
      - buylive_db
      - buylive_redis
    networks:
      - buylive_network
  buylive_db:
    container_name: "buylive_dev_db"
    image: "mysql:5.7"
    ports:
      - 3306:3306
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: "my2276"
    networks:
      - buylive_network
networks:
  buylive_network:
    driver: bridge

But he cannot execute XDEBUG normally

  • [V] I have tried with the latest version of my channel (Stable or Edge)
  • [V] I have uploaded Diagnostics
  • Diagnostics ID:B2037AE8-CCDF-4DF2-8421-F48231636A2A/20200602015137

@jakedowns
Copy link

jakedowns commented Jul 6, 2020

i'm having the same issue. somehow xdebug never seems to pick up on the request from the browser.
I'm trying to follow this guide currently to see if it's any help: https://www.silverf0x00.com/setting-up-xdebug-for-phpstorm-on-windows-wsl2/ so far i'm not having much luck.

I've tried setting xdebug.remote_host= manually to the IP of my wsl2 instance, and i've tried host.docker.internal which doesn't seem to work either. dunno if it's port 9000 that isn't making it all the way through or what. will keep digging...

quote-linking related issue microsoft/WSL#5277

Update: made some progress using this guide:

I ended up adding a portproxy from *:9009 to my WSL's IP:9009 in PowerShell (run as Admin)

PS C:\Windows\System32> netsh interface portproxy add v4tov4 listenport=9009 connectaddress=172.19.0.78 connectport=9009

PS C:\Windows\System32> netsh interface portproxy show all

Listen on ipv4:             Connect to ipv4:

Address         Port        Address         Port
--------------- ----------  --------------- ----------
*               9009        172.19.0.78     9009

now i'm finally getting output in my /var/log/xdebug.log "remote_log" file in my WSL2 Ubuntu > Docker Ubuntu container

my xdebug.ini:

xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9009
xdebug.remote_host=172.20.0.1
xdebug.remote_log = /var/log/xdebug.log

my workspace launch.json:

{
	"folders": [
		{
			"path": "./"
		}
	],
	"settings": {},
	"launch": {
		"version": "0.2.0",
		"configurations": [
			{
				"log": true,
				"name": "Listen for XDebug",
				"type": "php",
				"request": "launch",
				"hostname": "0.0.0.0",
				"port": 9009,
				"pathMappings": {
					"/var/www/": "./src/"
				}
			},
		]
	}
}

@docker-robott
Copy link
Collaborator

Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Nov 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants