Public | Automated Build

Last pushed: a day ago
Short Description
PHP5 on Apache (with SSL support), built on Debian
Full Description


This is an Apache image including SSL and PHP5 support. In order to use this image effectively, you'll need to mount:

  • /var/www/html for your site content (e.g. using "-v /home/jdoe/mysite/:/var/www/html/")
  • /var/log/apache2, optionally, if you want to store logfiles visibly outside the container
  • /etc/ssl, optionally, if you wish to use SSL with real keys

A note on SSL

As per the defaults, Apache will use the bundled "snakeoil" key when serving SSL. Obviously this isn't sufficient or advisable for production, so you'll want to mount your real keys onto /etc/ssl/. If you name them "certs/ssl-cert-snakeoil.pem" and "private/ssl-cert-snakeoil.key", you'll be able to get by with the default config. Otherwise, you'll want to include a revised site definition. If you don't want to use SSL, you can avoid forwarding port 443 when launching the container (see below).

Simple Examples

Assuming you have your content at /home/jdoe/mysite/, the below will be sufficient to serve it. Note that many Docker users encourage mounting data from a storage container, rather than directly from the filesyetem.

  • "It works!": docker run -p 80:80 -p 443:443 -d eboraas/apache-php and browse to the host's IP address using http or https
  • Serving actual content with SSL support: docker run -p 80:80 -p 443:443 -v /home/jdoe/mysite/:/var/www/html/ -d eboraas/apache-php
  • ... without SSL support: docker run -p 80:80 -v /home/jdoe/mysite/:/var/www/html/ -d eboraas/apache-php
  • ... using non-standard ports: docker run -p 8080:80 -p 8443:443 -v /home/jdoe/mysite/:/var/www/html/ -d eboraas/apache-php
Docker Pull Command
Source Repository

Comments (21)
3 months ago

ok I exit Kitematic and kill any process that might be running docker container

macHost:~ san$ ps -ef | grep docker
501 1694 1487 0 9:10PM ttys007 0:00.01 grep docker
but still I am able to open the page from the container using this IP : ! how is it happening, another thing I noticed if I refresh I see page not found if i refresh second time I get the default page of apache, and this can continue I dont know if docker is closed how I am still able to open this page ?

3 months ago

this might be very basic question, but I just downloaded this container via kitematic and ran this command
bash -c "clear && DOCKER_HOST=tcp:// DOCKER_CERT_PATH=/Users/sanjeevkumar/.docker/machine/machines/default DOCKER_TLS_VERIFY=1 docker exec -it apache-php sh"

and I am terminal of your container, however i cannot use vi / vim or ne / nano, so I want to access this container terminal from my mac , using ssh, but its asking me password which I dont know ! not metnioned anywhere in build details either. I would very much appreciate if you can please share it. Thanks

6 months ago


First thanks for your job !
That beeing said, I have an issue with mod_rewrite, I'm trying to use CakePHP but without url rewriting it just doesn't work. Did I miss something in the documentation to activate that or should it be activated by default and doesn't work ... or not just working at all ?

6 months ago

How can I access the files on container from host? Others containers have many volumes to configure docker files and local files. Here I not found. Someone can help me?

As said in the "Simple Examples" section, you should export the html directory ( -v /home/jdoe/mysite/:/var/www/html/ ) and you may do the same with the /etc/apache2 directory (-v /home/jdoe/config:/etc/apache2 )

7 months ago

How can I access the files on container from host? Others containers have many volumes to configure docker files and local files. Here I not found. Someone can help me?

a year ago

@mashermack "httpd already running" can be solved by running a "docker stop" before your "docker run" command

a year ago

Hello Eboraas, I can't find it anywhere but is it possible to launch the image with support for local .htaccess files?
I can't make run any CMS with pretty URLs activated.

Second thing, this image suffers the same "httpd (pid 6) already running" problem as any other images in the docker hub; when it crashes or doesn't end the container in a clean way the pid lock file still exists inside the container and Apache refuses to start.

Thanks a lot

a year ago

You're absolutely right. Thanks!

a year ago

Missing the directory html in all your examples.

It should be:
docker run -p 8080:80 -p 8443:443 -v /home/jdoe/mysite/:/var/www/html -d eboraas/apache-php

a year ago

@quentinv I am hoping to add a Stretch variant in the near future. I will likely base that variant on PHP 7, and will certainly make PHP 5 and PHP 7 variants available as Stretch approaches release.