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

290
Vistas
Pass Environment Variable to Apache PHP Docker Container

I have a PHP script that needs to reference a variable I input at runtime. I have built a docker image (I cannot build the variable into the image as it changes each time):

Here's my minimum working example:

index.php

<?php
$name = $_ENV["name"];
echo $name;
?>

Dockerfile

FROM PHP:apache

COPY index.php /var/www/html
RUN chown -R www-data:www-data /var/www

CMD ["apache2-foreground"]

I'm trying to spin it up with:

docker run -d -p 80:80 myimage:latest -e name=James

However, this fails as apache seems to have a flag called -e which reads the log level.

I'm sure I'm missing something fairly simple here!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You need to put all the flag before the docker image name as anything after the image name will be treated as cmd when starting the docker container.

With that being said, please try to create the container using the following command

docker run -d -e name=James -p 80:80 myimage:latest

Please refer to this link for more info.

over 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