2

Helle everyone.

I've a little issue with Docker. I try to create a basic docker-composer.yml for my projects with Laravel.

So here is my docker-compose.yml which is in the root directory of my project :

version: '2'
services:
    php:
        container_name: php
        build:
            context: ./
            dockerfile: docker/app.docker
        volumes:
            - ./:/var/www
        links:
            - mysql
            - redis
            - cache
        environment:
            - "DB_PORT=3306"
            - "DB_HOST=mysql"
            - "REDIS_PORT=6379"
            - "REDIS_HOST=redis"
    nginx:
        container_name: nginx
        build:
            context: ./
            dockerfile: docker/web.docker
        volumes:
            - ./:/var/www
        ports:
            - "80:80"
            - "443:443"
            - "9000:9000"
        links:
            - php
    mysql:
        container_name: mysql
        image: mysql:5.7.18
        environment:
            - "MYSQL_ROOT_PASSWORD=secret"
            - "MYSQL_DATABASE=docker"
        ports:
            - "3306:3306"
    redis:
        container_name: redis
        image: redis:3.0
        ports:
            - "6379:6379"
    cache:
        container_name: memcached
        image: memcached:alpine
        ports:
            - "11211:11211"

So as you can see, I try to install several containers : PHP, Nginx, MySql, Redis and Memcached.

Now here is my docker file for my PHP container :

FROM php:7.0-fpm
RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng-dev \
    && docker-php-ext-install -j$(nproc) iconv mcrypt \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd

It's the code I've found on the docker website.

But the docker-compose up command start well and crash while executing the configuration file.

It returns

Step 1/2 : FROM php:7.0-fpm
 ---> e04605d12f83
Step 2/2 : RUN apt-get update && apt-get install -y         libfreetype6-dev         libjpeg62-turbo-dev         libmcrypt-dev         libpng-dev     && docker-php-ext-install -j$(nproc) iconv mcrypt     && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/     && docker-php-ext-install -j$(nproc) gd
 ---> Running in fd19753fb969
ERROR: Service 'php' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y         libfreetype6-dev         libjpeg62-turbo-dev         libmcrypt-dev         libpng-dev     && docker-php-ext-install -j$(nproc) iconv mcrypt     && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/     && docker-php-ext-install -j$(nproc) gd' 
returned a non-zero code: 139

Does anybody already has this kind of error ? I've tried with PHP 7.1 fpm, same error is triggered.

I don't see what is wrong.

Do not hesitate to ask me some other parts of code.

Thanks for your help.

1 Answer 1

2

I tried your PHP configuration and it did not give me any problem when compiling the image

As an alternative: Try:

FROM php:7-fpm-alpine
RUN apk add --no-cache freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev && \
  docker-php-ext-configure gd \
    --with-gd \
    --with-freetype-dir=/usr/include/ \
    --with-png-dir=/usr/include/ \
    --with-jpeg-dir=/usr/include/ && \
  NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
  docker-php-ext-install -j${NPROC} gd && \
  apk del --no-cache freetype-dev libpng-dev libjpeg-turbo-dev
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your reply nasatome ! Whit your configuration, it seems to be good ! I have a successful message. Where did you get this configuration ? Docker (and adminsys) is new for me, so I don't understand everything. The 2 configurations are very different. Now I have an error with mysql, but it seems to be a port issue. Thank you again for you help :).
Take it out here: github.com/docker-library/php/issues/225#issuecomment-226870896 it is strange that the first configuration will not work ... sometimes they can be network problems, towards the ubuntu / debian servers, this other configuration is "alpine linux"
Worked for me, weird, i thought gd must be installed first, only then configured. How does it actually work?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.