This repository accompanies a tutorial series about leveraging Docker for local web development.
The current branch covers part 1 of the series, which is about setting up a basic LEMP stack with Docker Compose. Please refer to the full article for a detailed explanation.
This branch contains a basic LEMP stack running on Docker and orchestrated by Docker Compose, including:
This setup also uses localhost's port 80, so make sure it is available.
Add the following domain to your machine's
Clone the repository and change the current directory for the project's root:
$ git clone [email protected]:osteel/docker-tutorial.git $ cd docker-tutorial
$ cp .env.example .env
Run the following command:
$ docker-compose up -d
This may take a little bit of time, as some Docker images might need downloading.
Once the script is done, visit php.test (you might initially get a MySQL error message: this is because the database is still being created; the error will soon disappear upon refreshing the page).
The images used by the setup are listed and configured in
When building and starting the containers based on the images for the first time, a MySQL database named
demo is automatically created (you can pick a different name in the MySQL service's description in
src/ directory containing the application is mounted onto both Nginx's and the application's containers, meaning any update to the code is immediately available upon refreshing the page, without having to rebuild any container.
The database data is persisted in its own local directory through the volume
mysqldata, which is mounted onto MySQL's container. A phpMyAdmin interface is available at localhost:8080 (the database credentials are root / root).
Please refer to the full article for a detailed explanation.
To stop the containers:
$ docker-compose stop
To destroy the containers:
$ docker-compose down
To destroy the containers and the associated volumes:
$ docker-compose down -v
To remove everything, including the images:
$ docker-compose down -v --rmi all