skip to Main Content

I’m trying to set up my React + Laravel application with Docker, but I’m encountering an issue while running the composer install command inside the Docker container.

When I run docker-compose up -d --build, the build fails at the composer install step with the following error:

"[backend 8/9] RUN composer install –no-interaction –no-scripts –no-plugins:
#0 0.537 Composer plugins have been disabled for safety in this non-interactive session. Set COMPOSER_ALLOW_SUPERUSER=1 if you want to allow plugins to run as root/super user."

I have tried adding the COMPOSER_ALLOW_SUPERUSER=1 environment variable in various places, including in the Dockerfile, the docker-compose.yaml file, and even as a command-line argument when running docker-compose up. However, I still encounter the same error.

Here is an example of my docker-compose.yaml file:

version: '3'
services:
backend:
build:
context: .
dockerfile: Dockerfile
environment:
- COMPOSER_ALLOW_SUPERUSER=1
volumes:
- .:/app
# other service configuration...

2

Answers


  1. Chosen as BEST ANSWER

    You have to change the php version in the backend Dockerfile to a newer version

    FROM php:8.2
    

  2. If you want to use superuser for composer, you have to include

    ENV COMPOSER_ALLOW_SUPERUSER=1
    

    Before the composer install command in your Dockerfile.

    However, a safer option is to use a non-root user such as USER www-data in your Dockerfile instead of superuser.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search