Dealing with composer installation errors in Docker

Error that occurred

$ docker-compose up -d
ERROR: Service 'web' failed to build: The command '/bin/sh -c php composer-setup.php' returned a non-zero code: 1

Docker File before modification

# install composer
RUN php -r "copy('', 'composer-setup.php');"
RUN php -r "if (hash_file('sha384', 'composer-setup.php') === 'e5325b19b381bfd88ce90a5ddb7823406b2a38cff6bb704b0acc289a09c8128d4a8ce2bbafcd1fcbdc38666422fe2806') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
RUN php composer-setup.php
RUN php -r "unlink('composer-setup.php');"

Modified Docker File

# install composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

Recommended Posts

Dealing with composer installation errors in Docker
Install Composer with Docker
Docker installation
Alert slack with alert manager in Docker environment
Easy installation of Docker with snap (1 command)
Support for gdb errors in Docker containers
Scraping with puppeteer in Nuxt on Docker.
Commands that helped resolve errors in Docker
When dealing with whenever in Docker No such file or directory --crontab
Self-hosting with Docker of AuteMuteUs in Windows environment
Docker in LXD
[Note] Build a Python3 environment with Docker in EC2
How to delete untagged images in bulk with Docker
Database environment construction with Docker in Spring boot (IntellJ)
Docker installation on CentOS 6
Docker installation and initialization
Launch MariaDB with Docker
Rails deploy with Docker
Run Pico with docker
Use Puphpeteer with Docker
Try WildFly with Docker
Use ngrok with Docker
Run Payara with Docker
[Docker] Connection with MySQL
Php settings with Docker
Getting Started with Docker
Disposable PHP with Docker
Docker installation on WSL2
Write DiscordBot to Spreadsheets Write in Ruby and run with Docker