1
Good afternoon Devs all right, I’m having trouble trying to run Xdebug with Docker on Ubuntu 20.04. Below follows my config.
Docker-Compose.yml
version: '3.7'
networks:
supervisao:
services:
nginx:
image: nginx:stable-alpine
container_name: supervisao-web
ports:
- "80:80"
volumes:
- .:/var/www/html/
- ./.docker/web/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- php
- mysql
networks:
- supervisao
mysql:
image: mysql:latest
container_name: supervisao-db
restart: unless-stopped
tty: true
ports:
- "3306:3306"
volumes:
- ./.docker/mysql:/var/lib/mysql
environment:
MYSQL_DATABASE: supervisao
MYSQL_USER: user
MYSQL_PASSWORD: pass
MYSQL_ROOT_PASSWORD: pass
SERVICES_TAGS: dev
SERVICES_NAME: mysql
networks:
- supervisao
php:
build:
context: .
dockerfile: Dockerfile
container_name: supervisao-php
volumes:
- .:/var/www/html/
- ./.docker/php/docker-xdebug.ini:/usr/local/etc/php/conf.d/php-docker.ini
ports:
- "9000:9000"
networks:
- supervisao
redis:
image: redis:latest
volumes:
- ./.docker/redis:/data
ports:
- 6379:6379
networks:
- supervisao
.ini
# File: docker-xdebug.ini
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so
xdebug.discover_client_host=1
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_host = host.docker.internal
xdebug.client_port = 9003
xdebug.log = /var/www/html/xdebug.log
Launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"log": true,
"hostname": "0.0.0.0",
"pathMappings": {
"/var/www/html": "${workspaceFolder}"
},
"port": 9003,
"ignore": [
"**/vendor/**/*.php"
]
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003
}
]
}
If anyone has ever been through the same problem and can help.
You would have to see the log to try to locate the error, but taking a look at your Docker-Compose I think your network configuration is wrong, Voce must specify the drive. So my suggestion is that Voce colocque driver: bridge below the network name.
– Rafael Costa
@Rafaelcosta thanks for the feedback, would have an example of how to specify the driver in Compose??
– PaulinhoCaP
I put an example there in the answer, see that I declared the network at the end of the file.
– Rafael Costa