Docker Compose setup to run php5.3, php5.6 or php7 with php-fpm via nginx and mysql.
Create the ultimate development environment.
Install Docker and docker-compose. On Windows 10 install Docker Toolbox and disable Hyper-V.
- The webroot is at ./app/web
- You can put initial MySQL dump to the ./mysql/dump directory, it will be applied at the db container build. Format
*.sqlor*.sql.gz. Usedump.sql.exampleas an example. - The MySQL data will be stored at the ./mysql/databases directory. So data will be persistent between docker-compose runs.
- The MySQL root password is at docker-compose.yml
- Database access is host: db user: root password: (password from docker-compose.yml) database name: (name from dump in ./mysql/dump)
- On Linux.
git clone https://github.com/soft-industry/docker-compose-php.gitcd docker-compose-phpdocker-compose builddocker-compose up -d
- On Windows 10.
- Place the project within the Users directory
- Open Docker quickstart terminal
- Using command prompt navigate to the project directory
- Run
docker-compose buildanddocker-compose up -das usual
By default the setup creates a php5.6 environment, see docker-compose-php-7.yml how to use php7.
- On Linux.
- Open url http://localhost:8000
- On Windows 10.
- In the Docker quickstart terminal run
docker-machine ls - Open the ip of your docker machine with port 8000.
- In the Docker quickstart terminal run
docker-compose exec db bashwill open shell on the running db container.docker-compose stopwill stop running containers.docker-compose rm dbwill erase built db container. So when you rundocker-compose upit will be built again, and the initial dump will apply.$ docker exec some-mysql-contaner sh -c 'exec mysqldump -uroot -p"$MYSQL_ROOT_PASSWORD" db_name' > /some/path/on/your/host/db_name.sqlwill make dump fromsome-mysql-contanerand databasedb_nameinto local file.