Public | Automated Build

Last pushed: a year ago
Short Description
Docker image for Apache 2 and PHP 7
Full Description

Docker container with Apache 2 and PHP 7

Base docker image to run PHP applications on Apache

Usage

To run apache in a background process, simply start the container using the following command:

docker run -d -p 80:80 --name my-running-app mobilesnapp/apache-php7

-p 80:80 publishes port 80 in the container to 80 on the host machine.
-d detaches from the process, use docker ps and docker stop to … stop.

Sometimes you’ll want to debug issues with the container; maybe there are PHP configuration issues or you want to view error logs. To do that you can start the container in interactive mode and then start apache manually:

docker run -i -t -p 80:80 my-running-app /bin/bash
apachectl start

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).

Examples

If you’re actively developing you want to be able to change files in your usual editor and have them reflected within the container without having to rebuild it. The -v flag allows us to mount a directory from the host into the container:

docker run -p 80:80 -d -v /Users/myapp/site:/var/www/html --name my-running-app mobilesnapp/apache-php7

and browse to the host's IP address using http.

Serving actual content with SSL support:

docker run -p 80:80 -p 443:443 -d -v /Users/myapp/site:/var/www/html --name my-running-app mobilesnapp/apache-php7

Using non-standard ports:

docker run -p 8080:80 -p 8443:443 -d -v /Users/myapp/site:/var/www/html --name my-running-app mobilesnapp/apache-php7

Making Changes

If you’re actively developing you want to be able to change files in your usual editor and have them reflected within the container without having to rebuild it. The -v flag allows us to mount a directory from the host into the container:

docker run -p 80:80 -d -v /Users/myapp/site:/var/www/html --name my-running-app mobilesnapp/apache-php7

Author

MobileSnapp (support@mobilesnapp.com)

Docker Pull Command
Owner
mobilesnapp
Source Repository

Comments (0)