Docker Permissions in Symfony PHP

I’m having trouble getting this composition to work and hope someone can help me with it.

I’m getting a permission error when I try to build the container.

I already tried what explained here: https://symfony.com/doc/current/setup/file_permissions.html#using-acl-on-a-system-that-supports-setfacl-linux-bsd

But this isn’t fixing my issue.

Giving the files chmod -R 777 neither fixes it.

docker-compose.yml

version: '2'

services:
    server:
        image: nginx
        ports:
            - 80:80
        volumes:
            - ./server.conf:/etc/nginx/conf.d/default.conf
        volumes_from:
            - php

    php:
        image: php:fpm
        ports:
            - 9000:9000
        links:
            - database:mysqldb
        volumes:
            - .:/usr/share/nginx/symfony
        command: bash -c "docker-php-ext-install pdo_mysql && php-fpm"

    database:
        image: mariadb
        ports:
            - 3306:3306
        volumes:
            - ./.db:/var/lib/mysql
        environment:
            MYSQL_ROOT_PASSWORD: MYSQL_ROOT_PASSWORD

This is my server.conf

  server {
      index index.php index.html;
      server_name localhost;
      error_log  /var/log/nginx/error.log;
      access_log /var/log/nginx/access.log;
      root /usr/share/nginx/symfony/web;

      location ~ .php$ {
          try_files $uri =404;
          fastcgi_split_path_info ^(.+.php)(/.+)$;
          fastcgi_pass php:9000;
          fastcgi_index index.php;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_param PATH_INFO $fastcgi_path_info;
      }
  }

I want to run symfony with so i do this:

symfony new foo
cd foo
cp path/to/docker-compose.yml .
cp path/to/server.conf .
docker-compose up
firefox localhost:80/app.php

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *