Docker setup for creating multiple application in single host machine with named host for faster development.
In a fresh PC we need to install many things to run multiple PHP applications. To make the things easier, this repository consists of the most used docker images that are combined together to make multiple laravel applications up and running with a less amount of time.
- Install docker and docker-compose
- Clone this repo
- Copy
docker-compose.yml.sampletodocker-compose.yml. (`cp docker-compose.yml.sample docker-compose.yml) - Open
docker-compose.ymlwith any editor - Add a new container info in 'Custom applications' section or modify the existing containers info
- Remove the sections that are not necessary.
- Provide the IP address of a container in
ipv4_addressattribute ofnetworks. - Create a directory anywhere to store the data of your various databases. e.g.
/opt/dataand create 5 directories in that is described involumesproperties ofdatasection. Then change the mapping so that the left side of:part matches all the directories. e.g.
- /path/to/your-data-directory/mysql:/var/lib/mysql
- /path/to/your-data-directory/postgres:/var/lib/postgres
- /path/to/your-data-directory/memcached:/var/lib/memcached
- Save the file
- Copy
start.sampletostart. (cp start.sample start) - Open
startand change the 4th line so that it meets your custom application names. - Go to the root of the cloned repo and run
./start. - Add the urls in your
/etc/hostsfile that are defined inVIRTUAL_HOSTdirectives. - Browse the urls in your browser.
To reach one application from another application with named route,
provide the named route and IP in the extra_hosts section.
e.g. see laravel56-apache section.
From your host machine you can reach mysql at 127.0.0.1 as host.
e.g. From host run mysql -h 127.0.0.1 -u root -proot
From any docker container can reach mysql at 11.12.100.1 as host
e.g.: From container run mysql -h 11.12.100.1 -u root -proot
Note: Laraedit version is available in laravel-laraedit branch.