Docker Containerization MySQL + WordPress web installation on cloud AWS

Let's learn together and serve the society, Make India Proud.
Search for a command to run...

Let's learn together and serve the society, Make India Proud.
No comments yet. Be the first to comment.
Docker, an open-source platform, has transformed software development. It uses Microservice Arch. containerization for seamless application deployment across environments. Dive into Docker with us!
Question : How can I create a Dockerfile with a base image of Linux, such as Rocky Linux or CentOS, to deploy a web server (specifically httpd) on port 80? Additionally, I'd like to include the installation of prerequisite programs using yum install...
How Real Teams Deploy to Production: Kubernetes Deployment Strategies

Hello, this is Rakesh Kumar — your DevOps project practice trainer and your friend.I’m back again with a brilliant DevOps project that is not only production-ready but also highly valuable for real-world learning. This project is designed to take you...

Introduction If you are learning DevOps, you may be asking yourself: 👉 “I already know Bash scripting. Do I really need Python? Can’t I do the same work with Bash?” This is a common question, and the truth is: No, you don’t always need Python – Bas...

Project Idea – Build Your Own Mini Shell

Why every DevOps engineer needs Python in their toolkit

I am using here AWS Cloud infrastructure :
Ubuntu OS
T2.Medium Ec2 Instance
MobaXterm (ssh through Windows)

First of all we have to require to run MySQL container with some Environment variable using option -e like
-e MYSQL_ROOT_PASSWORD=
-e MYSQL_DATABASE=
# docker info
# docker --version
# docker pull mysql:latest
# docker pull wordpress:latest
# docker images
# docker run -d --name=mysql -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=wordpress mysql
# docker ps -a
# docker inspect mysql
root@wordpress:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
wordpress latest bc823df9ead2 8 days ago 668MB
mysql latest a3b6608898d6 5 weeks ago 596MB
root@wordpress:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a7f96e8a976c mysql "docker-entrypoint.s…" 23 minutes ago Up 23 minutes 3306/tcp, 33060/tcp mysql
Check MySQL container working and database has been created or not, so come into MySQL container using option docker exec -it mysql bash and check mysql database
root@wordpress:~# docker exec -it mysql bash
bash-4.4# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 8.2.0 MySQL Community Server - GPL
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| wordpress |
+--------------------+
5 rows in set (0.00 sec)
Now its time to launch WordPress container with some important environment variables like MySQL container image and some port information. We also can assign volume with docker containers. So lets launch wordpress container, and don't forgot to assign link between MySQL and Wordpress container.
docker run -d --name=wordpress --link=mysql
-p 8081:80 \
-e WORDPRESS_DB_HOST=mysql_container_IP:3306 \
-e WORDPRESS_DB_USER=root \
-e WORDPRESS_DB_PASSWORD=grras \
-e WORDPRESS_DB_NAME=wordpress \
-e WORDPRESS_TABLE_PREFIX=wp_
-v wordpress_vol:/var/www/html -d wordpress
Lets check the wordpress and mysql container status
root@wordpress:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
806e196f544f wordpress "docker-entrypoint.s…" 32 minutes ago Up 32 minutes 0.0.0.0:8081->80/tcp, :::8081->80/tcp wordpress
a7f96e8a976c mysql "docker-entrypoint.s…" 34 minutes ago Up 34 minutes 3306/tcp, 33060/tcp mysql
root@wordpress:~#
Congratulations your both containers are working fine and showing up status. Thats good. Let's explore wordpress site using http://Host_Machine_IP:3306 . we will take machines' public ip from the AWS instances dashboard.

