Giter Site home page Giter Site logo

docker-images-php's Issues

Cron job not running

Thanks for sharing this. I wanted to try this out for a project but I am having problems getting cron jobs working.

Expected Behavior

When I set CRON_COMMAND and CRON_SCHEDULE I expect the command to be executed as define by the schedule.

Current Behavior

When these commands are set the /etc/cron.d/generated_crontab file seems to be generated as expected but as far as I can tell the command is not executed.

I cannot tell why. Some form of logging might be helpful if possible.

Steps to Reproduce (for bugs)

  1. Create a docker-compose.yml file:
version: '3'
services:
  my_app:
    image: thecodingmachine/php:7.2-v1-apache
    environment:
      CRON_SCHEDULE: '* * * * *'
      CRON_COMMAND: 'php -r "echo time();"'
  1. Start the service docker-compose up
  2. Notice the output from Apache startup sequence in the output as expected
22:42 $ docker-compose up
Creating network "tmp_default" with the default driver
Creating tmp_my_app_1 ... done
Attaching to tmp_my_app_1
my_app_1  | [Fri Apr 27 20:42:16.690672 2018] [mpm_prefork:notice] [pid 8] AH00163: Apache/2.4.25 (Debian) PHP/7.2.4 configured -- resuming normal operations
my_app_1  | [Fri Apr 27 20:42:16.690749 2018] [core:notice] [pid 8] AH00094: Command line: 'apache2 -D FOREGROUND'
  1. I had expected there to be timestamps from the cron job in the output
  2. In another terminal run docker-compose exec my_app cat /etc/cron.d/generated_crontab. Output seems sensible enough

* * * * * root (php -r "echo time();") | sed -e 's/^/[Cron] /' > /proc/7/fd/1 2>/proc/7/fd/2

Your Environment

  • Version used: php:7.2-v1-apache and php:7.2-v1-cli
  • Operating System and version: OSX 10.13.4 + Docker for Mac 18.03.0-ce-mac60 (23751)

Missing mysql-client on fat image

Expected Behavior

I was expecting to see mysql-client on the fat image since mysql is the default database extension.

Current Behavior

Unable to make cli mysql database connections.

Possible Solution

apt-get install mysql-client

Steps to Reproduce

  1. which mysql

Context

You probably have a reason for not including mysql-client. But I wanted to ask anyway. I have no problem adding this to my own sub-image. But maybe you are open to installing it on the fat base images.

Your Environment

  • Version used: thecodingmachine/php:7.2-v2-apache-node10
  • Operating System and version: Linux 350f1de01c97 4.15.0-42-generic #45-Ubuntu SMP Thu Nov 15 19:32:57 UTC 2018 x86_64 GNU/Linux
  • Link to your project: https://github.com/verbruggenalex/php-c9

pdo as extension does not exist

In the documentation in almost all examples of building slim images the extension "pdo" is used - an example:

ARG PHP_EXTENSIONS="apcu mysqli opcache pdo pdo_mysql redis zip soap" directly under "Compiling extensions in the slim image".

But "pdo" is not a valid extension when trying to build the container - this is my output (for php 7.2 slim cli, the same with slim fpm):

Building container
Step 1/16 : ARG PHP_EXTENSIONS="opcache pdo pdo_mysql zip"
Step 2/16 : FROM thecodingmachine/php:7.2-v2-slim-cli
# Executing 7 build triggers
 ---> Using cache
 ---> Running in 548c6d0e99cd
Removing intermediate container 548c6d0e99cd
 ---> Running in ca7979a4a321
*** Installing extensions ***
The following extension(s) is not supported: pdo
Supported extensions: amqp, apcu, ast, bcmath, blackfire, bz2, calendar, dba, ds, enchant, ev, event, exif, gd, gettext, gmp, gnupg, igbinary, imagick, imap, intl, ldap, mailparse, mcrypt, memcached, mongodb, mysqli, opcache, pcntl, pcov, pdo_dblib, pdo_mysql, pdo_pgsql, pgsql, pspell, redis, shmop, snmp, soap, sockets, swoole, sysvmsg, sysvsem, sysvshm, tidy, wddx, weakref, xdebug, xmlrpc, xsl, yaml, zip

I suspect this is just a documentation error, but it is in all the examples and in the list of valid extensions, so it is likely people will stumble over it, as I did.

Can't use volume to map /var/www/html

Hi

I am using

version: '3'
services:
  my_app:
    image: thecodingmachine/php:7.3-v2-apache-node10
    environment:
      # Enable the PostgreSQL extension
      PHP_EXTENSION_PGSQL: 1
      # Disable the Mysqli extension (otherwise it is enabled by default)
      PHP_EXTENSION_MYSQLI: 0
      #APACHE_DOCUMENT_ROOT: /var/www/html
    ports:
      - "2080:80"  

    volumes:
      - /media/var/www/html:/var/www/html

However I cant seem to be able to acces any of the webapps under /media/var/www/html I am not sure what I am missing here.

"GET /webapp/ HTTP/1.1" 404 506 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0

I am using Docker on Debian Buster x64
thanks

Redis module does not seem to load with default values

Your issue may already be reported!
Please search on the issue tracker before creating one.

Expected Behavior

Redis module should be loading by default

Current Behavior

Redis module does not load

Possible Solution

Steps to Reproduce (for bugs)

  1. Run docker image with echo php modules php -m
    Returns: php modules [PHP Modules] bcmath bz2 calendar Core ctype curl date dba dom exif fileinfo filter ftp gd gettext gmp gnupg hash iconv imagick imap intl json ldap libxml mbstring mcrypt mongodb mysqli mysqlnd odbc openssl pcntl pcre PDO pdo_mysql PDO_ODBC pdo_pgsql pdo_sqlite pgsql Phar posix readline recode Reflection session shmop SimpleXML snmp soap sockets SPL sqlite3 standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl Zend OPcache zip zlib [Zend Modules] Zend OPcache

Context

Your Environment

  • Version used: 7.2-v1
  • Operating System and version:
  • Link to your project:

Amend documentation about CMD / ENTRYPOINT for CLI

When using the CLI images, it is implied that you should set a CMD (and this is shown in the one CLI example via command line), but it would help if at least one docker compose example and/or Dockerfile example showed this explicitely - it could be a CLI example running phpunit, which would be a common use case.

I tried setting up an ENTRYPOINT instead of a CMD, which overwrote the ENTRYPOINT of the image and lead to unexpected results (like php.ini settings not being set up), so a warning not to use ENTRYPOINT in a Dockerfile might also help, as most docker tutorials advise on using ENTRYPOINT instead of CMD, or using both together for executable containers.

Add custom extension

I use the image thecodingmachine/php:7.2-v2-apache (the 7.3 is not on docker hub), and I want to add a custom extension in php. I have a .so, but how can I add automatically in the extension directory and enable it ?

I found the extension directory but the name is /usr/local/lib/php/extensions/no-debug-non-zts-20170718/ and I don't know how can I automatically get it.

Is it possible to add easily a custom .so extension ?

No default command for PHP-CLI

There is no default command for PHP CLI. This leads to weird error message when called with no commands.

$ docker run thecodingmachine/php:7.2-v1-cli

usage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
            [command]
usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
            prompt] [-u user] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
            prompt] [-u user] file ...

TODO: add a default command (maybe "php -a" ?)

Slim Image, ARG not working in multistage build

Using this Dockerfile:

FROM thecodingmachine/php:7.2-v2-apache-node10 AS builder

COPY --chown=docker:docker sources/web .

ENV APP_ENV=prod \
    APACHE_DOCUMENT_ROOT=/public

RUN composer install &&\
    yarn install &&\
    yarn build

ARG PHP_EXTENSIONS="apcu mysqli opcache pdo pdo_mysql zip soap"
FROM thecodingmachine/php:7.2-v2-slim-apache

ENV APP_ENV=prod \
    APACHE_DOCUMENT_ROOT=/public

COPY --from=builder /var/www/html .

No errors, but the process says:

*** Installing extensions ***
array(0) {
}
No extensions installed in ONBUILD hook.
`
``

CRON STDOUT

STDOUT not working for the cron. > /proc/1/fd/1 2>/proc/1/fd/2 in file generate_cron.php

PHP-FPM versions is not works

Hi there!

When I use the fpm version, the php-fpm process does not start and the container shutdown without any errors but with the output of sudo usages. In scripts that run automatically when the container starts, there are no commands to run the php-fpm process. Also, there is no launch of the php-fpm process in the Dockerfile.fpm file. I fixed it but your Dockerfile.fpm is not correct.

user@host:~ $ docker run -p 9000:9000 -v /home/user/code:/var/www/html thecodingmachine/php:7.2-v1-fpm

usage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
            [command]
usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
            prompt] [-u user] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
            prompt] [-u user] file ...

user@host:~ $

Install Blackfire

That would be awesome if Blackfire was preinstalled in the Docker images. That would allow to profile PHP scripts very easily.

To make that happen the following needs to be done in the Docker images:

Users not using Blackfire should not be impacted because the extension will not do anything. (it could also be possible to make the extension opt-in through an environment variable, that would be even cleaner)

Users using Blackfire will need to:

Curl SSL certificate missing?

Expected Behavior

PHP Curl requests to HTTPS URLs should succeed

Current Behavior

Requests are failing

Possible Solution

Looks like it's something to do with cacert.pem not being found
https://docs.bolt.cm/3.6/howto/curl-ca-certificates

Steps to Reproduce (for bugs)

  • Using image thecodingmachine/php:7.2-v2-fpm
  • In a PHP script, use Curl to request an HTTPS url
  • See error SSL certificate problem: unable to get local issuer certificate when the curl request fails.

Docker 18.09.5 is on Linux Mint 19

XDebug Extension Not Loading

Expected Behavior

XDebug extension is enabled

Current Behavior

XDebug extension is not enabled

Steps to Reproduce (for bugs)

Use this docker-compose.yml:

version: '3.3'

services:
     php:
          image: thecodingmachine/php:7.2-v2-apache
          ports:
               - "8080:80"
          volumes:
               - ./:/var/www/html
          environment:
               PHP_EXTENSION_XDEBUG: 1
               PHP_INI_XDEBUG__REMOTE_ENABLE: 1
               PHP_INI_XDEBUG__REMOTE_AUTOSTART: 1

image

Missing PECL uploadprogress on fat image

Expected Behavior

When using image for Drupal I expect to see the PECL uploadprogress library on the image.

Current Behavior

Not present. Drupal status report page mentions it not being enabled.

Possible Solution

RUN git clone https://github.com/php/pecl-php-uploadprogress/ /usr/src/php/ext/uploadprogress/ \
&& docker-php-ext-configure uploadprogress \
&& docker-php-ext-install uploadprogress \
&& rm -rf /usr/src/php/ext/uploadprogress

Context

This is really dependent on whether your project requires the uploadprogress library. Just thought I'd share with you my work.

Environment

  • Version used: thecodingmachine/php:7.2-v2-apache-node10
  • Operating System and version: Linux 350f1de01c97 4.15.0-42-generic #45-Ubuntu SMP Thu Nov 15 19:32:57 UTC 2018 x86_64 GNU/Linux
  • Link to your project: https://github.com/verbruggenalex/php-c9

Installing PHP Image Magick

How can I install image magick into this for use with PHP?

Maybe something like this?

RUN apt-get update && apt-get install -y \
        libmagickwand-dev --no-install-recommends \
    && pecl install imagick-beta \
     && docker-php-ext-enable imagick \
    # Clean Up \
    && rm -rf /var/lib/apt/lists/*

Version: thecodingmachine/php:7.2-v1-apache-node10

Or should I do it as a start-up command or make my own dockerfile that inherits from yours?

To test if loaded a php file like this should output available formats.

<?php
if(extension_loaded('imagick')) {
    $imagick = new Imagick();
    print_r($imagick->queryFormats());
}
else {
    echo 'ImageMagick is not available.';
}

The environment variable way

STARTUP_COMMAND_1: "sudo apt-get update && sudo apt-get install -y php-imagick"

Gives me this error.
E: Package 'php-imagick' has no installation candidate

Error with PHP exif extension

I've enabled the exif extension using PHP_EXTENTION_EXIF: 1 and phpinfo() confirms that it is enabled. However, when I call exif_read_data() I get the following error: Call to undefined function exif_read_data().

I've recreated the error on two separate machines. I've even gone as far as to run the code on a XAMPP stack to ensure my code works. I've been able to turn on other extensions--this one is the first time I've had trouble with this.

Running docker on Windows 10. Using the php:7.2-v2-apache-node10 image.

Modules lost in CI

In a CI environment, if a project runs:

sudo composer install

all custom PHP settings are lost (!)

This is because "sudo" loses all environment variables and because "composer" actually points to a script that will first regenerate php.ini conf (because we need to generate conf for "composer install" if run inside a Docker build where conf has not been generated yet)

We need to find a way to make sure the conf is regenerated when composer is called ONLY if we are in a Dockerfile and not when we are in a container running.

Crons are not executed as correct user if there is a ";" in the command

Expected Behavior

CRON_COMMAND_1: id; id
CRON_USER_1: docker

There are 2 "id" commands run. They should both execute as the "docker" user.

Current Behavior

First id is executed by "docker", second by "root".

This is because the command executed is:

/bin/sh -c sudo -E -u docker id; id

Imagick for slim image

I noticed that Imagick extension cannot be enabled (it is not on the list of available extensions) when slim container is used. Can that be fixed somehow?

Fat image works fine with this extension

Feature Request: Cloud9 IDE

First off, I want to say this is by far the best docker environment I've ever seen around. Super dynamic, easy to use and very extensive. I was just wondering if you would consider adding a dev image that includes the Cloud9 IDE. If this was a possibility then I could trow out my PC forever:

2019-01-07-06-38-05-html-Cloud9

I can understand you might not want to add C9 to your dev images. But if anyone of the team is interested in it, I'd love to work together to create a sub-image with them.

Let me know if there's any team members that are into exploring the idea. If there's absolutely no interest you can close this issue and I'll explore it myself.

Here's an installation example of C9 (it does add +/- 400 MB to the image):

Dockerfile
FROM thecodingmachine/php:7.2-v2-cli-node10

USER root

RUN buildDeps='make build-essential g++ gcc python2.7' && softDeps="tmux locales" \
&& apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y $buildDeps $softDeps --no-install-recommends \
&& locale-gen en_US.UTF-8 \
&& localedef -f UTF-8 -i en_US en_US.UTF-8

user docker

RUN git clone --depth 1 https://github.com/c9/core.git /home/docker/cloud9
WORKDIR /home/docker/cloud9
RUN git pull origin master\
&& NO_PULL=1 scripts/install-sdk.sh \
&& git reset --hard

USER root

RUN apt-get purge -y --auto-remove $buildDeps \
&& apt-get autoremove -y \
&& apt-get autoclean -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

USER root

RUN npm cache clean --force

USER docker
EXPOSE 8080
WORKDIR /var/www/html

CMD /usr/bin/node /home/docker/cloud9/server.js -l 0.0.0.0 -p 8080 -w /var/www/html -a :

Best regards,
Alex

Startup commands issues for some owners on the directory containing docker-compose.yml file

There are issues using STARTUP_COMMAND in docker-compose.yml file (tested on Ubuntu 17.10).

With STARTUP_COMMAND_1: composer install :

sudo: no tty present and no askpass program specified
php_apache_node exited with code 1

With STARTUP_COMMAND_1: npm install :

Error: EACCES: permission denied, mkdir '/home/docker/.npm'

Solution : my directory containing the docker-compose.yml file was owned by www-data:www-data.
Changing owning of the directory to ${USER} solved the issues.

Memcached issue

Hello,

When enabling the memcached PHP extension, I get the following error:

PHP Warning:  PHP Startup: Unable to load dynamic library 'memcached.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/memcached.so (libmemcached.so.11: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/memcached.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/memcached.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

My service:

front:
    image: thecodingmachine/php:7.2-v1-apache-node8
    working_dir: /var/www/html/front
    labels:
      - traefik.enable=true
      - traefik.backend=front
      - traefik.frontend.rule=Host:foo.localhost
    environment:
      APACHE_DOCUMENT_ROOT: front/
      PHP_INI_MEMORY_LIMIT: 1g
      PHP_EXTENSION_XDEBUG: 1
      PHP_EXTENSION_BCMATH: 1
      PHP_EXTENSION_INTL: 1
      PHP_EXTENSION_GD: 1
      PHP_EXTENSION_MEMCACHED: 1
      STARTUP_COMMAND_1: composer install
      STARTUP_COMMAND_2: yarn install
      STARTUP_COMMAND_3: gulp js less css
    env_file:
      - .env
    volumes:
      - .:/var/www/html:rw

Image does not work on Bitbucket Pipelines

Expected Behavior

When I add PHP_EXTENSION_INTL=1 to my bitbucket pipelines env variables, I expect the intl extension to be loaded.

Current Behavior

Currently, it is not loaded. When I run echo $PHP_EXTENSION_INTL, it outputs 1.

Possible Solution

I think bitbucket only injects the user configured env variables after it has booted the container.

Errors in STARTUP_COMMAND_XXX are not fatal

When an error occurs in STARTUP_COMMAND_XXX, the container does still start.

It would be a better practice to halt the container if any startup command returns an error. Otherwise, the error might go unnoticed.

Permission denied issue when using php's internal web server

Expected Behavior

I'd like to use the php:7.2-v1-cli using php's internal web-server

Current Behavior

Session files (like /usr/src/app/var/sessions/dev/sess_b769a9b5b9f1f3e2b57b739f5788aca9 ) are owned by root, triggering errors

Steps to Reproduce (for bugs)

  1. in a symfony project using the web server bundle, use this docker-compose.yml
services:
    php:
        command: php bin/console server:run 0.0.0.0:8000
        ports:
            - "8000:8000"
        image: thecodingmachine/php:7.2-v1-cli
        volumes:
            - .:/usr/src/app
        environment:
            PHP_INI_MEMORY_LIMIT: -1
            PHP_EXTENSION_GNUPG: 1
  1. execute docker-compose up php
  2. open browser on http://127.0.0.1:8000

The error should happen immediatly

Warning: SessionHandler::read(): open(/usr/src/app/var/sessions/dev/sess_b769a9b5b9f1f3e2b57b739f5788aca9, O_RDWR) failed: Permission denied (13)

Context

I've been using php-cli with php's internal web server like this until now and thought I'd give your image a try using the same approach. Ironically, it was the permission "black magic" that motivated my switch :-)

Your Environment

OS : archlinux
docker 18.06.1-ce

Enabling amqp extension results in a broken setup

Expected Behavior

I expect that my configuration of a container:

  php-cli:
    image: 'thecodingmachine/php:7.2-v1-cli'
    volumes:
      - './:/usr/src/app:delegated'
    environment:
      PHP_EXTENSION_AMQP: 1

is correct and creates a container with amqp extension enabled.

Current Behavior

I'm running docker-compose up with the config above.
and see

php-cli_1   | PHP Warning:  PHP Startup: Unable to load dynamic library 'amqp.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/amqp.so (librabbitmq.so.4: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/amqp.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/amqp.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
php-cli_1   | time="2018-10-20T21:19:29Z" level=info msg="read crontab: /tmp/generated_crontab"
php-cli_1   | time="2018-10-20T21:19:29Z" level=fatal msg="bad crontab line: Warning: PHP Startup: Unable to load dynamic library 'amqp.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/amqp.so (librabbitmq.so.4: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/amqp.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/amqp.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0"
php-cli_1   | PHP Warning:  PHP Startup: Unable to load dynamic library 'amqp.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/amqp.so (librabbitmq.so.4: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/amqp.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/amqp.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
php-cli_1   | bash: line 2: syntax error near unexpected token `('
php-cli_1   | bash: line 2: `Warning: PHP Startup: Unable to load dynamic library 'amqp.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/amqp.so (librabbitmq.so.4: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20170718/amqp.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20170718/amqp.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0'

and non-working container.

Your Environment

  • Version used: php:7.2-v1-cli
  • Operating System and version: macOS High Sierra

Dynamic PHP_EXTENSIONS

Hi, great job ๐Ÿ‘
I want to set PHP_EXTENSIONS variable dynamically in my Dockerfile.

ONBUILD ENV PHP_EXTENSIONS=$(cat /var/www/html/exts.txt)

But Docker doesn't allow it. Can you please help me to do it?

Add support for php.ini variables containing special chars

My php container that connects to redis (with password)

api:
    image: thecodingmachine/php:7.1-v1-apache
    ...
    environment:
      ...
      PHP_INI_SESSION__SAVE_HANDLER: redis
      PHP_INI_SESSION__SAVE_PATH: "tcp://redis:6379?auth=123"

When I try to access redis session store, I get the following error :
session_start(): open(tcp://redis:6379?auth/sess_p6rqfk7phj43d477k37d3iecb4, O_RDWR) failed: No such file or directory

It seems that the the variable has been stripped after the equal sign.

Extensions not installed when running Composer in Dockerfile

FROM thecodingmachine/php:7.1-v1-cli
ENV PHP_EXTENSION_GD=1
RUN composer install

If the composer.lock contains a package that requires "gd" to be enabled, "gd" will not be yet available (because it is enabled at container startup time only).

We should overwrite "composer" executable to make sure we enable the extensions before composer startup.

Files ownership problem when running internal commands

Hi there !

It seems that the "black magic" used for permissions has some "dark effects" ๐Ÿ˜„.
When I execute a command whithin the container, the files generated from it belong to root and not to the docker user.

For instance, I have an Angular application in an app folder mapped into /var/www/html. If i run npm install from the host, the owner will be the docker user as expected. But, if I run the command from the container (with the docker user), it will generate a node_modules folder that belongs to root !

Otherwise, it's a hell of a docker image ๐Ÿ‘

/var/www/html directory is owned by root on Php:7.2-v2-fpm image (Windows)

Expected Behavior

When I get inside the php-fpm container, my volume mounted in /var/www/html should be owned by "docker" user.

Current Behavior

It's owned by "root" user instead.
Executing a chown docker:docker /var/www/html doesn't work, neither from the Dockerfile, nor from inside the container itself.

Steps to Reproduce (for bugs)

Here is my Dockerfile :

FROM thecodingmachine/php:7.2-v2-fpm

COPY ["./conf/log.conf", "/usr/local/etc/php-fpm.d/zz-log.conf"]

USER root

# pre-req
RUN apt-get update
RUN apt-get install --no-install-recommends -y \
    zip \
    locales \
    libicu-dev \
    apt-transport-https \
    libpng-dev \
    libzip-dev \
    libxml2-dev \
    libpng-dev
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
RUN locale-gen

# ssl 1.0.0
RUN echo 'deb http://httpredir.debian.org/debian jessie main contrib non-free' >> /etc/apt/sources.list.d/jessie.list \
    && echo 'deb-src http://httpredir.debian.org/debian jessie main contrib non-free' >> /etc/apt/sources.list.d/jessie.list \
    && echo 'deb http://security.debian.org/ jessie/updates main contrib non-free' >> /etc/apt/sources.list.d/jessie.list \
    && echo 'deb-src http://security.debian.org/ jessie/updates main contrib non-free' >> /etc/apt/sources.list.d/jessie.list \
    && apt-get update
RUN apt-get install libssl1.0.0

# sqlsrv pre-req
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
    && curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list \
    && apt-get update
RUN ACCEPT_EULA=Y apt-get install -y \
    unixodbc \
    unixodbc-dev \
    libgss3 \
    odbcinst \
    msodbcsql \
    msodbcsql17 \
    mssql-tools
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc

# install php ext
RUN pecl install sqlsrv pdo_sqlsrv
RUN docker-php-ext-enable sqlsrv pdo_sqlsrv

# spring cleaning
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*

USER docker

WORKDIR /var/www/html

And the "php" service in my docker-compose.yml :

php:
    build:
      context: .
      dockerfile: dockerfile-php
    container_name: php
    env_file:
      - .env
    environment:
      PHP_EXTENSION_INTL: 1
      PHP_EXTENSION_GD: 1
      PHP_EXTENSION_XDEBUG: $DEBUG
      STARTUP_COMMAND_1: composer install
    volumes:
      - ./code/backend:/var/www/html
    networks:
      - net

Also, I'm working on Windows 10 (Professionnal), with Docker for Windows (Linux containers).

Timezone issue with Crons

Crons seems to be triggered at the UTC date (because the default timezone for the container is UTC, whatever the timezone of the host).

We should probably document this and provide guidance on how to set the timezone in a container.

Crontab user must be root

When the user is not root the cron isn't executed.
I try to create a file with this:

echo "oui">/var/www/html/test.txt

This work for root and not for other user.

Xdebug remote host

Expected Behavior

When enabling the Xdebug extension with PHP_EXTENSION_XDEBUG=1, the Xdebug remote host should be set automatically.

Current Behavior

The variable xdebug.remote_host is empty

Possible Solution

More a workaround, but we are able to temporary fix this by using PHP_INI_XDEBUG__REMOTE_HOST=ip/docker.for.mac.localhost

Steps to Reproduce (for bugs)

  • Enable Xdebug with PHP_EXTENSION_XDEBUG=1
  • Restart the container
  • Run php -i in the container

Your Environment

  • Version used: PHP-Apache 7.1
  • Operating System and version: Linux / MacOS

Allow APACHE_DOCUMENT_ROOT to be set outside of /var/www/html

Expected Behavior

I think that APACHE_DOCUMENT_ROOT should be allowed to be set outside of /var/www/html. Since regular Apache configuration allows it.

Current Behavior

Currently you can only set a subfolder of /var/www/html:
https://github.com/thecodingmachine/docker-images-php/blob/v2/Dockerfile.7.2.slim.apache#L77-L80

Possible Solution

The solution would be to set the default to /var/www/html and if the variable is set override the entirety of the default instead. Problem is that I don't see a way that keeps backward compatibility without introducing a secondary variable.

Context

The reason for me requesting this is because on my development environment I'm using Docker in Docker setup to control my environment from inside. When using docker-compose you'd want to have the path be the exact same as on your host system. This allows you to docker-compose ps your docker system.

Cron php not found

In cron configuration, I try to apply php -v but php is not found by default.

ZipArchive::setEncryptionName is not defined (ziplib is not up to date)

ZipArchive::setEncryptionName should have been available since PHP 7.2. However, I get the error Call to undefined method ZipArchive::setEncryptionName() when using the function.

When checking out phpinfo, I see that libzip version 1.1.2 is used. Research indicates that this must be increased to version 1.2.0.

Expected Behavior

ZipArchive::setEncryptionName() should be defined.

Current Behavior

ZipArchive::setEncryptionName() is not defined.

Possible Solution

Update libzip to version 1.2.0 or newer.

Steps to Reproduce (for bugs)

$zip = new ZipArchive();
if ($zip->open('test.zip', ZipArchive::CREATE) === TRUE) {
    $zip->setPassword('secret');
    $zip->addFile('text.txt');
    $zip->setEncryptionName('text.txt', ZipArchive::EM_AES_256);
    $zip->close();
    echo "Ok\n";
} else {
    echo "KO\n";
}

Your Environment

  • Version used: thecodingmachine/php:7.2-v1-apache-node10
  • Operating System and version: Windows 10

XDEBUG remote host detection fails in V2

The 'host' command use to define xdebug configuration doesn't exists in the image.
So, ```DOCKER_HOST_INTERNAL=`host -t A host.docker.internal | awk '/has address/ { print $4 }'```` can't be proceed.

PHP max_execution_time is not respected

docker run -it --rm -e PHP_INI_MAX_EXECUTION_TIME=60 thecodingmachine/php:7.1-v2-cli php -r "phpinfo();" | grep max

Expected Behavior

max_execution_time => 60 => 60

Current Behavior

max_execution_time => 0 => 0

I don't know why is it like that. Any ideas:

lsb_release -a                                                                                                                                                                                                                                                               
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.1 LTS
Release:	18.04
Codename:	bionic

Extensions isnt compiled and added when using Dockerfile.7.3.slim.fpm

Hi,

Ive been struggling with this for a while now, I cant understand what Iam doing wrong.

Im using Dockerfile.7.3.slim.fpm with this structure:
/php-slim/Dockerfile
/php-slim/extensions
/php-slim/utils

And ive added ARG PHP_EXTENSION at the top of the Dockerfile:
ARG PHP_EXTENSIONS="gettext apcu opcache pdo pdo_mysql zip soap intl"
ARG INSTALL_CRON=1
FROM php:7.3-fpm-stretch

None of the extensions gets compiled/installed when i build. If I add this manually below line 16:
RUN cd /usr/local/lib/thecodingmachine-php/extensions/current/gettext && ./install.sh
RUN cd /usr/local/lib/thecodingmachine-php/extensions/current/intl && ./install.sh

Those (two) extensions gets installed & compiled as intended. What am I doing wrong? Ive cleaned my cache, downloaded the image from scratch and gets same result each time. Using Dockerfile.7.3.fpm (fat) as Dockerfile works with the extensions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.