Public Repository

Last pushed: 2 years ago
Short Description
Complete Docker LAMP Image for Laravel 5 (projects stored on the main host).
Full Description

This Docker image run all projects you have stored on your local host and it may also use mysql persistent data. I will show how bellow.

This container was built with:

  • Linux Ubuntu Trusty;
  • Apache 2.4.7
  • Mysql 5.5.46
  • PHP 5.5.9 (work with Laravel Framework 5.2.6)
    and
  • Composer

Suppose you have a main folder for your project (in your host machine) named projects. Inside this folder you have another 2 folders (one with laravel project and another to store mysql data), like this:

projects/
├── example
├── myproject
│ ├── app
│ ├── artisan
│ ├── bootstrap
│ ├── composer.json
│ ├── composer.lock
│ ├── config
│ ├── database
│ ├── gulpfile.js
│ ├── package.json
│ ├── phpunit.xml
│ ├── public
│ ├── readme.md
│ ├── resources
│ ├── server.php
│ ├── storage
│ ├── tests
│ └── vendor
└── mysql_data

Note: SELinux provides extra protection for containers or from containers. If this is your case you need to run the next command:

chcon -Rt svirt_sandbox_file_t mysql_data/

Usage

  1. Go to the project folder
    $ cd projects/example

  2. Download and Start the LAMP Laravel server instance

$ docker run \
--name myproject \
--hostname myproject \
--publish 80:80 \
--volume $(pwd)/myproject:/var/www \
--publish 3306:3306 \
--volume $(pwd)/mysql_data/:/var/lib/mysql \
-e dbname=myproject -e dbuser=admin -e dbpass=admin \
-d vyanix/lamp-laravel

The above command run or download (if not exists) the container with name and hostname myproject, expose 80 and 3306 ports, mount local laravel and mysql persistent data folders inside the container and create the database with the name myproject and the user and pass admin.

  1. Test if the Laravel Framework is running
    Point your brower to
    http://localhost

  2. Get ip of the running container and test mysql access from main host:
    $ docker inspect --format '{{ .NetworkSettings.IPAddress }}' myproject
    «IP Myproject»
    $ mysql -u admin -p -h «IP Myproject» -P3306

  3. To give bash session in the container, run:
    $ docker exec -it myproject bash

Inside the container you can confirm versions and tests:

$ cd /var/www/
$ composer diagnose

Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking composer version: OK

$ composer self-update

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty

$ apache2 -v
Server version: Apache/2.4.7 (Ubuntu)
Server built: Oct 14 2015 14:20:21

$ php artisan -V
Laravel Framework version 5.2.6

$ php --version
PHP 5.5.9-1ubuntu4.14 (cli) (built: Oct 28 2015 01:34:46)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

$ mysql --version
mysql Ver 14.14 Distrib 5.5.46, for debian-linux-gnu (x86_64) using readline 6.3

  1. [Optional] Stop the lamp docker server instance
    docker stop myproject

  2. [Optional] Delete the lamp docker server instance (after stopping it)
    docker rm -f myproject

Have a nice day ;)

Docker Pull Command
Owner
vyanix

Comments (0)