0

My docker-compose file:

version: '3.8'

services:
  cache:
    image: memcached:latest
    restart: always
    ports:
      - "10001:11211"

  server:
    build: '.'
    tty: true
    working_dir: /var/www
    environment:
      DISABLE_DEFAULT_SERVER: 1
      AUTORELOAD_PROGRAMS: "kid_api"
      AUTORELOAD_ANY_FILES: 1
    volumes:
      - ../../Apps/Server:/var/www
      - ./php/config/custom.ini:/usr/local/etc/php/conf.d/custom.ini
      - ./supervisor/kid_api.conf:/etc/supervisor/service.d/kid_api.conf
    ports:
      - "9988:9988"
    depends_on:
      - cache
    links:
      - cache

My Api.php file into /var/www open socket port for daemon server with Swoole.

When i tried docker-compose up, then ports is ok:

CONTAINER ID   IMAGE                          COMMAND                  CREATED        STATUS        PORTS                      NAMES
4c80bee2baf7   php74_swoole4510_base_server   "/entrypoint.sh"         2 hours ago    Up 1 second   0.0.0.0:9988->9988/tcp     php74_swoole4510_base_server_1
3b0f67cc3295   memcached:latest               "docker-entrypoint.s…"   24 hours ago   Up 2 hours    0.0.0.0:10001->11211/tcp   php74_swoole4510_base_cache_1

but if i tried to run with PhpStorm

enter image description here enter image description here

then the ports are not open

CONTAINER ID   IMAGE                          COMMAND                  CREATED         STATUS                  PORTS                      NAMES
a7b534100202   php74_swoole4510_base_server   "php /var/www/Api.php"   2 seconds ago   Up Less than a second                              php74_swoole4510_base_server_run_df9a640e18bb
3b0f67cc3295   memcached:latest               "docker-entrypoint.s…"   24 hours ago    Up 2 minutes            0.0.0.0:10001->11211/tcp   php74_swoole4510_base_cache_1

How fix it?

4

1 回答 1

0

docker-compose up不等于docker-compose run
PhpStorm 可以docker-compose run service_name command
在这种情况下,Docker Compose 本身不会映射端口,您可以在终端中查看。

您可以docker-compose up在终端中手动启动服务,然后在exec模式下使用 PhpStorm(该选项在您的屏幕截图中可见)。

于 2020-12-29T15:19:31.730 回答