A
A
Alexander Pankov2022-03-04 15:55:15
PHP
Alexander Pankov, 2022-03-04 15:55:15

How to set up xdebug on Ubuntu in Docker?

Hello, there is a vps with ubuntu
on it, a docker, inside of which there is a clean project on laravel

, here is the compose config

version: '3.1'

services:
  mailhog:
    image: 'mailhog/mailhog:latest'
    ports:
      - '18025:8025'
  
  mysql:
    image: 'mysql:8.0'
    working_dir: /application
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=example
      - MYSQL_USER=mysql
      - MYSQL_PASSWORD=mysql
    ports:
      - '13306:3306'

  webserver:
    image: 'nginx:alpine'
    working_dir: /application
    volumes:
      - './src:/application'
      - './docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf'
    ports:
      - '180:80'

  php-fpm:
    build: docker/php-fpm
    working_dir: /application
    volumes:
      - './src:/application'
      - './docker/php-fpm/php-ini-overrides.ini:/etc/php/8.1/fpm/conf.d/99-overrides.ini'
    environment:
      APP_ENV: dev
      APP_DEBUG: 1
      XDEBUG_CONFIG: "client_host=192.168.200.1 client_port=9003"
      PHP_IDE_CONFIG: "serverName=example"

networks:
  default:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 192.168.200.0/28


the project is spinning on vps,
I want to be able to debug it locally (the files are locally and appear on vps using rsyn)

php.ini config
xdebug.mode = debug
xdebug.idekey = PHPSTORM


as I understand the action plan
1) we make it so that the php container can send data to vps port 9003
2) on the local machine we do "forwarding port 9003" all that comes to vps port 9003 is broadcast to my computer, and on the computer phpstorm is already properly configured.

In general, I run containers
there in index.php I write xdebug_info and see such errors

[Step Debug] Creating socket for '192.168.200.1:9003', poll success, but error: Operation now in progress (29)
[Step Debug] Could not connect to debugging client. Tried: 192.168.200.1:9003 (through xdebug.client_host/xdebug.client_port) :-(


What do they mean?
Why do they appear?
How to fix them?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question