WordPress is one of the most popular content management software and there are different methods available for the installation. In this blog article we are using a docker compose yml file for installation. A Docker container is a standard piece of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. It simplify the installation process to a single deployment command and reduces the time and effort required. All these are achieved by the use of Docker containers of each service needed by the WordPress, like using MariaDB,WordPress files and phpMyAdmin.
In other words Defined the services that make up my WordPress website in
docker-compose.yml so they can be run together in an isolated environment.
So lets get started. I tested WordPress docker image and the compose file in Ubuntu 20.04
How to install the Docker.
This is needed to run the docker containers in our Ubuntu 20.04.
First we need to setup Docker repository on a newly installed system.
Update apt package index and install packages to allow apt to use a repository over HTTPS
Add Docker’s official GPG key
Use below command to set up the stable repository.
Install the Docker Engine
Verify that Docker Engine is installed correctly bu running “hello-world” container.It prints message as the installation appears to be working correctly.
Install Docker Compose
Now we had the docker engine installed in the server which is necessary to run the docker compose command in a Linux servers. So lets proceed with the install of Docker compose. Issue below commands for the installation.
Check the docker compose command by verifying the version.
Setup WordPress with Compose
We use the official WordPress Docker container and the MySQL docker image for the WordPress setup.
Create an empty project directory.
create a docker-compose.yml file.
Copy the below content and save the file.
Lastly bring up the WordPress using the command “docker-compose up -d“. At this point the WordPress url is available at server IP address. If we point our domain name to this IP address, we can browse our WordPress website using domain name itself. if we visit the domain in our browser, we can see the WordPress install page.
To list the running containers, issue below command
Use “netstat” command to see the port 80 is listening. Also make sure to open the port 80 in the server firewall.
We can also see the WordPress related files are available in the directory /root/wordpress/wp_html and database files in /root/wordpress/db folder.
We can set any value for below environment variables. All we need to make sure is, use same value for identical variables.
To bring down the docket setup we can use the command “docker-compose down –volumes” – removes the containers, default network, and the WordPress database. This conclude the installation of wordpress using docker compose yml file. Leave your thoughts at the comment box.