Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

179
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda