Public Repository

Last pushed: 2 years ago
Short Description
Base docker image to run PHP applications on Apache
Full Description

tutum-docker-php

Base docker image to run PHP applications on Apache

Building the base image

To create the base image tutum/apache-php, execute the following command on the tutum-docker-php folder:

docker build -t tutum/apache-php .

Running your Apache+PHP docker image

Start your image binding the external ports 80 in all interfaces to your container:

docker run -d -p 80:80 tutum/apache-php

Test your deployment:

curl http://localhost/

Hello world!

Enable .htaccess files

If you app uses .htaccess files you need to pass the ALLOW_OVERRIDE environment variable

docker run -d -p 80:80 -e ALLOW_OVERRIDE=true tutum/apache-php

Loading your custom PHP application

This image can be used as a base image for your PHP application. Create a new Dockerfile in your
PHP application folder with the following contents:

FROM tutum/apache-php

After that, build the new Dockerfile:

docker build -t username/my-php-app .

And test it:

docker run -d -p 80:80 username/my-php-app

Test your deployment:

curl http://localhost/

That's it!

Loading your custom PHP application with composer requirements

Create a Dockerfile like the following:

FROM tutum/apache-php
RUN apt-get update && apt-get install -yq git && rm -rf /var/lib/apt/lists/*
RUN rm -fr /app
ADD . /app
RUN composer install
  • Replacing git with any dependencies that your composer packages might need.
  • Add your php application to /app
Docker Pull Command
Owner
tutum

Comments (4)
bbohara
6 months ago

Trying to commit into new image "test"

I am trying to run the new image and I see the error

sudo docker run --name bhakti test
==> /var/log/apache2/access.log <==

==> /var/log/apache2/error.log <==
[Tue Mar 28 23:00:27.244510 2017] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.11 configured -- resuming normal operations
[Tue Mar 28 23:00:27.244685 2017] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

==> /var/log/apache2/other_vhosts_access.log <==
httpd (pid 1) already running

Seems like: https://github.com/docker-library/php/issues/187

Could you please add it ?

thuydungtrinh
9 months ago

docker run -d -p 80:80 username/my-php-app

--> what is "username" for???

magicmonkey
2 years ago

A friendly word of caution: if you try to volume-mount into /app then you'll end up with all of your files owned by www-data due to a line in the run.sh file.

hxh1246996371
2 years ago

when I run docker run -d -p 80:80 username/my-php-app I just see the page like docker run -d -p 80:80 tutum/apache-php not my php app,why?