Kevin
Kevin

Reputation: 5082

Docker and symfony

I'm struggling with Docker.

I'm tring to create an image to work on symfony project and to learn Docker in the same time. Here is my Dockerfile:

FROM php:7-apache

LABEL Description = "This image is used to start Symfony3 project"

ENV DIRPATH /var/www/html

# apt-get command
RUN apt-get update && apt-get install -y \
    vim \
    git \
 && apt-get clean

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer

# Install the Symfony Installer
RUN curl -LsS http://symfony.com/installer -o /usr/local/bin/symfony
RUN chmod a+x /usr/local/bin/symfony

I build the image with the command:

docker build -t symfony .

Works well! Cool!

I'm create a container with:

docker run --name symfony -d -v "$PWD":/var/www/html -p 80:80 symfony

Works well also. The web server is running on the good port.

I can go in my container with:

docker exec -ti symfony bash

But when I'm trying to do a composer update, I have some errors:

Failed to download symfony/symfony from dist: Could not decompress the archive, enable the PHP zip extension.
A php.ini file does not exist. You will have to create one.

How can I create the php.ini in Dockerfile?

I also think that I have an issue with permission. When I'm trying to the web/app_dev.php I have this message:

You are not allowed to access this file. Check app_dev.php for more information.

Upvotes: 1

Views: 2353

Answers (2)

Andru
Andru

Reputation: 6184

Next to the missing php.ini file you should also install zip so you can download from dist, i.e.

RUN docker-php-ext-install zip

Which will install and enable the PHP zip extension which is requested in your error message.

Upvotes: 0

Matteo
Matteo

Reputation: 39380

You can ADD a custom php.ini configuration specifing it in the dockerfile, As Example, you can take a look at this repo for this example:

dokerfile

# install a few more PHP extensions
RUN apt-get update && apt-get install -y php5-imagick php5-gd php5-mongo php5-curl php5-mcrypt php5-intl

# copy a custom config file from the directory where this Dockerfile resides to the image
COPY php.ini /etc/php5/fpm/php.ini

You can find various approach and various sample on the net.

Hope this help

Upvotes: 1

Related Questions