Wanted to learn on how to setup WordPress using docker? Read this tutorial till the end.
Normally, one would set up an Apache (LAMP) or Nginx (LEMP) server to host the WordPress websites. Instead of using a bare server, you also can use docker and/or docker-compose to set up the required software to host your WordPress sites.
A common docker setup is to create a separate container for each service. In this case, you would have at least three containers; Apache/Nginx, PHP, and MySQL/MariaDB.
But I also have seen people putting all services into one single container which is not an appropriate way of using docker in my opinion.
Set Up WordPress using Docker
To setup WordPress using docker-compose LEMP stack, just follow these steps.
How to update Nginx configuration in Docker?
You can use either your own docker file script, add a custom Nginx configuration when building the Nginx container, or you can use mount directory or volumes to include your additional Nginx configuration in the docker container.
Besides, you also can edit the default Nginx configuration file directly within the container, but if you recreate the container, the customization will be reset.
To go inside Nginx docker container:
docker exec -it nginx sh
Then you can edit the default configuration file:
vi /etc/nginx/conf.d/default.conf