edyan / docker-xhgui

An xhgui (with nginx, mongodb and php) container for profiling PHP Applications.
https://hub.docker.com/r/edyan/xhgui/
Apache License 2.0
25 stars 8 forks source link

No mongodb connection / incorrect ip binding? #2

Closed fbrinker closed 6 years ago

fbrinker commented 6 years ago

Hello, I've tried to use this container with the following docker-compose setup:

version: '2'
services:
  xhgui:
    image: edyan/xhgui
  api:
    hostname: api
    build: 
      context: .
      dockerfile: ./docker/php-7/Dockerfile
    ports:
      - "80:80"
    links:
    - xhgui
    volumes_from: [xhgui]
    volumes:
      - ./xhgui-config.php:/usr/local/src/xhgui/config/config.php
      - ./src:/var/www/html/
      - ./docker/vhosts/:/etc/apache2/sites-enabled/

But when opening xhgui, I get the error that it can't connect to mongodb (mongodb://xhgui). The host "xhgui" is reachable inside the docker network and I've found out that the problem is mongodbs bind_ip setting. It's set to localhost by default. How is this supposed to work?

I've started it via mongod --bind_ip=0.0.0.0 and it worked. Is this setup only for the usage with Stakkr or do i use it the wrong way? :)

fbrinker commented 6 years ago

Nevermind... I've tried to access it via a vhost in the api-container ...

fbrinker commented 6 years ago

Okay XHGui worked but I couldn't send any new profiling data anymore.

The api container needs to send the data to the mongodb server inside the xhgui container. Is there any other intended solution then setting bind_ip to 0.0.0.0? I'm overwriting the supervisord.conf for now.

Any thoughts on this?

edyan commented 6 years ago

Hi sorry for the delay, I got no notification that the issue was opened. I'll review my notifications settings. Nevertheless, I don't know your "api" image as it looks like a local build. I have reproduced that with my own docker-compose.yml :

version: '2'
services:
  xhgui:
    image: edyan/xhgui:php7.2
    # I need to access xhgui
    ports:
      - "9000:80"
    volumes:
      - ./xhgui-config.php:/usr/local/src/xhgui/config/config.php
  php:
    hostname: php
    image: edyan/php:7.2
    # To have the new mounted volumes as well as the default volumes of xhgui (its source code)
    volumes_from: [xhgui]
    volumes:
      - ./src:/var/www

  # the visible part
  api:
    hostname: api
    image: edyan/apache:2.4-slim
    ports:
      - "8000:80"
    volumes:
      # /var/www is my default document root in that image
      - ./src:/var/www
      # I have no specific virtualhost
      # - ./docker/vhosts/:/etc/apache2/sites-enabled/

# Launched with : docker-compose up --force-recreate
# then I call "http://localhost:8000/index.php" in my browser
# then I get the report from http://localhost:9000.

I think it's related to the edyan/php7.2 that I have updated from debian to ubuntu. To fix that I have done what you said and updated the image on docker hub as well as the doc.

Can you test and tell me if it works ? Thanks