Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

291
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda