1

I have created a docker image, tested it locally. All working well.

After that I used the same Dockerfile - built it and run it on EC2.

The Apache webserver is listening to the connections, I have opened firewall in EC2 machine security settings, but if I try to navigate to the webisite, it seems to be opening for approx 2.5 minutes.

And then the website OPENS. Each navigation step takes 2.5 minutes.

Later:

I have tried to replicate this environment on Windows machine with Virtual Box and it has exactly same issue. Website would take long time and eventually open. It also broke connect to another machine that that was completely not docker related (Ubuntu dev box)

Can anybody advice something?

Here is docker file:

FROM ubuntu
RUN apt-get update -y
RUN apt-get install -y apache2 php5 vim libapache2-mod-php5 php5-mcrypt 

RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid
EXPOSE 80
RUN ln -sf /dev/stderr /var/log/apache2/error.log
CMD /usr/sbin/apache2ctl -D FOREGROUND
Adam
  • 3,415
  • 4
  • 30
  • 49
  • On Windows, how do you run your container, and do you port-forward the port you have chosen to publish 80? (http://stackoverflow.com/a/35019160/6309) – VonC Jan 28 '16 at 12:04
  • I meant: let's try to solve it first locally on Windows. – VonC Jan 28 '16 at 13:46
  • I had xdebug enabled. Seemed that it didn't do any charm on Ubuntu host, but once I disabled xdebug it started working on both - Windows Virtual box an don EC2. Thanks for your support @VonC – Adam Jan 28 '16 at 13:53
  • Do you mean you set `xdebug.remote_enable=off` in `/usr/local/etc/php/conf.d/xdebug.ini`? Or were you starting your image with `docker run -e XDEBUG_CONFIG="remote_host={{YOUR_IP_ADDRESS}}" your-image`? – VonC Jan 28 '16 at 13:57
  • I was install installing `apt-get install php5-xdebug` and then in my php.ini [xdebug] zend_extension="/usr/lib/php5/20121212/xdebug.so" xdebug.remote_enable=on xdebug.remote_handler=dbgp xdebug.remote_host=172.17.0.1 xdebug.remote_port=9000 xdebug.remote_connect_back=on xdebug.remote_autostart=on xdebug.remote_log="/var/log/xdebug/xdebug.log" – Adam Jan 28 '16 at 13:59
  • Yes. I will need to find a better strategy to do debugging. – Adam Jan 28 '16 at 14:00
  • It is really strange that this can slow down the response time of the website. – Adam Jan 28 '16 at 14:06
  • I agree. Maybe try to set some settings off to see if one part of that setup was the culprit. – VonC Jan 28 '16 at 14:07

1 Answers1

2

As illustrated in "Debug your PHP in Docker with Intellij/PHPStorm and Xdebug", it is possible to debug php from within a container.

The OP activated it directly in php.ini:

[xdebug]
  zend_extension="/usr/lib/php5/20121212/xdebug.so" 
  xdebug.remote_enable=on xdebug.remote_handler=dbgg
  xdebug.remote_host=172.17.0.1
  xdebug.remote_port=9000
  xdebug.remote_connect_back=on
  xdebug.remote_autostart=on
  xdebug.remote_log="/var/log/xdebug/xdebug.log" 

Removing that module was enough to bring the response time down.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250