Learn how to install WordPress with Docker to speed up your WordPress website deployment. You can deploy WordPress easily in your new VPS cloud server or dedicated server, using Docker. Alternatively, you can also install WordPress directly in your new server. There are benefits and shortfalls in each deployment methods but having your own VPS server gives you the flexibility to choose your preference.
Summary
- You already have a Scalable VPS server on AlmaLinux 8
- Install Docker on AlmaLinux 8
- Setup MariaDB Docker Container
- Install WordPress with Docker
Installing WordPress with Docker
- Firstly, let us pull WordPress docker using the following command:
docker pull wordpress
- Before we proceed further, let us learn the environment variables and docker parameters below:
-e WORDPRESS_DB_PASSWORD= Set the same database password here.
–name wordpress – Gives the container a name.
–link wordpressdb:mysql – Links the WordPress container with the MariaDB container so that the applications can interact. You should have created “wordpressdb” when you install MariaDB docker container
-p 80:80 – Tells Docker to pass connections from your server’s HTTP port to the containers internal port 80.
-v “$PWD/html”:/var/www/html – Sets the WordPress files accessible from outside the container. The volume files will remain even if the container was removed.
-d – Makes the container run on background
wordpress – Tells Docker what to install. Uses the package downloaded earlier with the docker pull wordpress -command. - We can now execute the following command to complete the installation with docker:
docker run -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=password-here –name wordpress –link wordpressdb:mysql -p 80:80 -v “$PWD/html”:/var/www/html -d wordpress - Finally, you may complete WordPress installation by using your browser to visit your server and complete the web-based wizard.
Conclusions
This article shows you how you can install WordPress with Docker. If you find yourself using a fairly reliable stack and on consistent development platform, perhaps Docker is an unnecessary abstraction to add to your team’s workflow. However, if your team struggles with developer support on a platform level, Docker just might be the thing that makes the difference.