Generic PHP Apache Docker container
Generic PHP Apache docker container built on CentOs 7.
Note: This repo just serves as a base image for building PHP/Apache based containers. You can extend this by using the existing image (the result of this Docker file repo) at https://registry.hub.docker.com/u/lysender/php-apache/ by Docker Hub.
You must have at least Docker 1.6.2 where this Dockerfile is tested. It is also nice to have a fast internet connection or best if you do this on a VPS or some cloud hosting account.
For testing purposes, like a hello workd application (in our case, a phpinfo() output), we can build the image this way.
Note: I prefer to create images and containers as a regular user. You may choose to run it as root.
# Clone this repo git clone firstname.lastname@example.org:lysender/docker-php-apache.git cd docker-php-apache # Build image, you can use any tag name docker build --rm -t lysender/php-apache . # Create and run a container on poart 8080 docker run --name sample-php -d -p 8080:80 lysender/php-apache
The first part (building the image) will take some time to complete. Fast connection helps.
After building, we create a container based on the newly created image, configure it to run as a daemon
-d, map the exposed port to
8080 where it maps to the containers port
The output is a
phpinfo() page based on our sample
Site does not load? Try checking if the container is still running.
It should show the currently running containers. It
sample-php container is not listed, or has exited for some reasons, then there are issues when the image or container.
TODO: Add more troubleshooting information.