Tag: php

composer install fails when unable to see mysql database

TL;DR: composer install fails when the post-install scripts can’t see a MySQL server I’m building a docker container for a Symfony application, and during the build I do something like this RUN export SYMFONY_ENV=prod && \ composer install –prefer-dist –optimize-autoloader Towards the end of the install, it fails with this Generating optimized autoload files [Doctrine\DBAL\Exception\DriverException] […]

Docker best practices: single process for a container

The Docker best practices guide states that: “…you should only run a single process in a single container…” Should Nginx and PHP-FPM run in separate containers? Or does that mean that micro service architectures only run one service or “app” in a container? Having these services in a single container seems easier to deploy and […]

Why might Docker Compose restart be rendering container output an increasing number of times?

I am writing a web app based on Docker Compose, and it has a number of background systems – an HTTP API, a HTTP proxy and a queue. Everything is in PHP in Alpine containers, either PHP 5.6 or 7.0. I originally set up the queue in Supervisor inside the API container, which worked fine. […]

Docker php-fpm/nginx set-up: php-fpm throwing blank 500, no error logs

Git repo of project: https://github.com/tombusby/docker-laravel-experiments (HEAD at time of writing is 823fd22). Here is my docker-compose.yml: nginx: image: nginx:stable volumes: – ./nginx.conf:/etc/nginx/conf.d/default.conf:ro volumes_from: – php links: – php:php ports: – 80:80 php: image: php:5.6-fpm volumes: – ./src:/var/www/html expose: – 9000 Into src/ I’ve created a fresh laravel project. This all functions correctly if I swap […]

How to enable pdo_mysql in the php docker image

I have a basic Dockerfile with the following in: FROM php:7.1-apache RUN apt-get update && docker-php-ext-install pdo_mysql COPY . /var/www EXPOSE 80 I have a docker-compose.yml file version: “3” services: app: build: . ports: – “80:80” volumes: – .:/var/www depends_on: – mysql mysql: image: mysql:8 ports: – “3306:3306” environment: MYSQL_DATABASE: “app” MYSQL_USER: “app” MYSQL_PASSWORD: “app” […]

How can I use XDebug with a PHP upstream behind an nginx reverse proxy?

I have a PHP server running through PHP-FPM which is served with fastcgi through nginx on port 7000. This application has been dockerized and is running as a running container, e.g. my_api. The my_api docker container can be connected to directly via port 7000 (for sanity checking) as well as through another container which acts […]

Project layout with vagrant, docker and git

So I recently discovered docker and vagrant, and I’m starting a new Php project in which I want to use both: Vagrant in order to have a interchangeable environment that all the developers can use. Docker for production, but also inside the vagrant machine so the development environment resembles the production one as closely as […]

Proper handling of request_uri in double nginx reverse proxy?

So, essentially I am running Joomla in a Docker php7-fpm container, then I have an nginx container where a joomla.conf file is defined as follows: #https://docs.joomla.org/nginx server { listen 8081; error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; server_name php-docker.local; root /usr/src/joomla; index index.php index.html index.htm default.html default.htm; location / { try_files $uri $uri/ /index.php?$args; } # deny running […]

How can I debug php mounted to a container running on docker beta for mac

I have spent half the day trying different things including this solution I came across on gist.github.com I have a docker-compose file which mounts a folder containing my client and server projects: volumes: – ~/projectx:/projectx my docker php.ini contains the following xdebug options [xdebug] xdebug.remote_enable=1 xdebug.remote_port=9000 xdebug.remote_connect_back=On xdebug.var_display_max_children = 999 xdebug.var_display_max_data = 999 xdebug.var_display_max_depth = […]

Why PHP-FPM prefixes a warning when writing to stdout?

I try to run a Yii based PHP application in a Docker container using the official php-fpm image. It’s common practice for docker containers to write all log messages to stdout / stderr. So I do the same from my container with a code that basically looks like this: $fp = @fopen(‘php://stdout’,’w’); fwrite($fp, $message); fclose($fp); […]

Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.