Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
Using Docker, how do you execute PHP composer commands?

I'm new to Docker and got my PHP environment set up with this as my Dockerfile:

FROM php:7.0-apache
COPY src/ /var/www/html/

Now I want to use PHP code I found on github and it says to install it I simply have to do:

composer require league/oauth2-client

Upon getting a shell into my docker container composer isn't even installed. How do I add composer into the Dockerfile and then execute the composer commands I need?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I was able to solve this by adding this to the Dockerfile

RUN php -r "copy('https://getcomposer.org/installer', 'composer- setup.php');"
RUN php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer
RUN php -r "unlink('composer-setup.php');"
RUN composer require league/oauth2-client
about 4 years ago · Santiago Trujillo Report

0

Upon getting a shell into my docker container

That would be at runtime (docker run)

Instead, create a new Dockerfile, which starts with FROM myimage (the php image you created), and add / copy what is missing.

See for instance "Get composer (php dependency manager) to run on a docker image build" as a possible approach.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!