Composer plugins disabled in Docker: Set COMPOSER_ALLOW_SUPERUSER=1 to enable plugins

Stefan Izdrail

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Composer Plugins Disabled in Docker: Set COMPOSER_ALLOW_SUPERUSER=1 to Enable Plugins Body:

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...
The issue you're facing is a common one when using composers inside your non-interactive containers. The default setting for Composer in containers prevents the usage of plugins, which causes the error that you are seeing. To enable plugins in these situations, simply set the environmental variable COMPOSER_ALLOW_SUPERUSER=1, as mentioned earlier. However, this solution is not always enough to solve your problem. To achieve a stable environment, you can also try the following steps: 1. Specify the location of Composer binaries in the Docker image by adding these lines to your Dockerfile:
RUN curl -s https://getcomposer.org/installer | php
   RUN mv composer.phar /usr/local/bin/composer
This ensures that you have the latest Composer version and simplifies its usage. 2. Add the following to your Dockerfile:
ENV COMPOSER_HOME /tmp
   WORKDIR /tmp/composer-install
   RUN /usr/local/bin/composer create-project --prefer-dist --no-dev laravel/laravel laravel-app && \
      mv ./laravel-app/* . && \
      (cd .. ; rm -rf composer-install)
This step installs the Laravel project, moves it into your application directory, and removes the temporary Composer files created during this process. 3. Modify your docker-compose.yaml file as shown below:
version: '3'
services:
  backend:
    build:
      context: .
      dockerfile: Dockerfile
    environment:
      - COMPOSER_ALLOW_SUPERUSER=1
    volumes:
      - ./app:/app
# other service configuration...
This setup ensures that the Laravel application files are correctly mounted into your container, allowing you to take advantage of the customized Dockerfile and environment variable settings. By following these steps, you should be able to successfully install your React + Laravel application inside a Docker container, while enabling Composer plugins for a seamless development experience.