Composer plugins disabled in Docker: Set COMPOSER_ALLOW_SUPERUSER=1 to enable plugins
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
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...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/composerENV 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)version: '3'
services:
backend:
build:
context: .
dockerfile: Dockerfile
environment:
- COMPOSER_ALLOW_SUPERUSER=1
volumes:
- ./app:/app
# other service configuration...