In this article, I will show you how to install WordPress in AWS EC2 using Docker.
What is Docker
According to WiKi, Docker is a set of the platform as service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuration files; they can communicate with each other through well-defined channels. At the time when I am writing this, docker is considered one of the most popular container systems in this World. Many organizations of different sizes use docker in their development environment as well as the production environment.
How to setup WordPress with Docker
In this article, I will show you How to Setup WordPress Using Docker in AWS which can help you to really get started with AWS + docker + WP
At first, we need to update YUM. YUM (Yellowdog Updater Modified) is an open-source command-line as well as graphical-based package management tool for RPM (RedHat Package Manager) based Linux systems. It allows users and system administrators to easily install, update, remove, or search software packages on a system. So sudo yum update -y basically updates all packages to its the latest version from a repository list which is managed by Amazon for Amazon Linux 1. This is always a good practice to run “yum update” first before you install any software.
#update yum package sudo yum update -y
Once YUM is updated then run this command to install Docker in Amazon Linux.
#install docker sudo yum install docker -y
After installing Docker, let’s pull some images from Docker Hub. The first image we will pull is MySQL’s official image. At the time when I am writing, the stable version was MySQL 5.7.29, which is used here.
#pull docker image for mysql docker pull mysql:5.7.29
Next, we will pull WordPress Image.
#pull docker image for wordPress docker pull wordpress
When you have pulled both images, then run this command to run WordPress into your EC2 instance.
#run to start docker with wordpress with msyql docker run --name wordpressdb -e MYSQL_ROOT_PASSWORD=tutorial -e MYSQL_DATABASE=wordpress -d mysql:5.7.29 docker run -e WORDPRESS_DB_PASSWORD=tutorial -d --name wordpress --link wordpressdb:mysql -p 80:80 -v "$PWD/":/var/www/html wordpress
In summary, docker is the most popular container system and you should learn how to install WordPress using docker so that you can have a smooth development and production environment. I have created a video tutorial on this topic as well which is given below. Feel free to subscribe to my channel to see more tutorials like this.