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

287
Views
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 answers
Answer question

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 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!