Public | Automated Build

Last pushed: a year ago
Short Description
PHP 5.5.9 plus Apache 2.4.7 built from Ubuntu Trusty and with Xdebug ready for work image autobuild
Full Description

Simple Docker environment for LAMP development.

First steps


  • Create a copy of docker-compose.yml.default and name it as docker-compose.yml:
    $ cp docker-compose.yml.default docker-compose.yml
  • Create an empty data directory at your home directory ~:
    $ mkdir ~/data
  • Change the volumes mapping from default to the path where you have the source code. This will ensure that you're putting your (SSHFS or other) mapped device into /var/www at the container each time it start or run.
      - <your_mount_path>:/var/www
      - ~/data:/data
  • If you want to change the default PHP_ERROR_REPORTING change it on docker-compose.yml before run the command below. Default to error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE.

Build and run containers

$ docker-compose up -d

Yes!!!! That's it!!! You'll get all you need to run PHP applications.

Note: Because the containers will be running in background mode (-d option) you might attach to the running container by running docker attach <container_name> and might have to press a key to get the prompt of your container. Another way to access the running containers is using docker exec -it <container_name> /bin/bash

Note: When you're building your image and container you could get the following warning [Warning] IPv4 forwarding is disabled. Networking will not work. this means in some distros the IPv4 forwarding is disabled and Docker doesn't enabled it by default since this could be dangerous(see here). In order to fix it create the following file /usr/lib/sysctl.d/docker-ip-forwarding.conf and add this content net.ipv4.ip_forward = 1 after that restart Docker by running service docker restart. The above fix will only work in distros where systemd is supported (most distributions use it nowdays).

Access apache logs

Apache is configured to log both access and error log to STDOUT. So you can simply use docker logs to get the log output: docker logs -f <container-name>

Installed packages

  • Ubuntu Server 14.04.5 LTS, based on Ubuntu docker image
  • Apache 2.4.7
  • PHP 5.5.9-1
    • php5-gd
    • php5-json
    • php5-mcrypt
    • php5-mysql
    • php5-xdebug
    • php5-curl
    • php5-memcached
  • Zend Framework
  • Nano
  • PHP MongoDB extension from PECL (upgrade to latest version compatible with newest MongoDB releases)

Note: Each time you build or rebuild an image and the container it runs an update this means libraries will get updated to the latest version available on the repository by the time it happen. At the time when this repo where created/updated the major version of Apache was 2.4.7, PHP was 5.5.9 and Zend Framework was 1.11.11.

Other useful packages installed

  • Composer
  • PHP Libraries
    • Code Sniffer (will be installed at /home/docker-user/.composer/vendor/bin/phpcs)
    • Mess Detector (will be installed at /home/docker-user/.composer/vendor/bin/phpmd)

Setup phpStorm, Xdebug and Docker

Guide to setup phpStorm, Xdebug and Docker

General notes

  • On some linux hosts all docker commands need to be run with sudo
  • To see all images: "docker images"
  • To see all containers: "docker ps -a"
  • To remove an image: "docker rmi <image_id>" (image must not have any containers based on it)
  • To remove a container: "docker rm <container_id>" (container must not be running)
  • To exit a container shell session and leave the container running use ^p ^q
Docker Pull Command
Source Repository