- Регистрация
- 1 Мар 2015
- Сообщения
- 1,481
- Баллы
- 155
Hi everyone,
My name is Soumen Bhunia. This is my first blog. In this blog, I build and deploy my first Node.js app using Docker, hosted on an AWS EC2 instance, and connected to a MySQL database hosted via Amazon RDS
Technologies Used
Step 1: Create an RDS MySQL Instance
After RDS is created, copy the endpoint/hostname — you'll use it to connect your app to the database.
Step 2: Launch and Configure an EC2 Instance
Once connected to EC2, run the following:
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -aG docker ec2-user
Important: Log out and log back in to activate Docker permissions for ec2-user.
Step 4: Run the Dockerized Node.js App
Pull the Docker image:
sudo docker pull philippaul/node-mysql-app:02
Then run your container, replacing the values with your actual RDS credentials:
docker run --rm -p 80:3000 \
-e DB_HOST="your-db-endpoint.rds.amazonaws.com" \
-e DB_USER="admin" \
-e DB_PASSWORD="your-db-password" \
-d philippaul/node-mysql-app:02
Your app should now be accessible at your EC2 public IP on port 80.
Web interface screenshot
Optional: Test the MySQL Connection
You can test connecting to the database from inside EC2 using a MySQL Docker client:
docker run -it --rm mysql:8.0 mysql \
-h your-db-endpoint.rds.amazonaws.com \
-u admin -p
Enter your password when prompted. If you connect successfully — your EC2 can talk to your RDS instance.
Wrapping Up
Thank you for investing your time in reading this article! I hope these insights have provided you with practical value and a clearer understanding of the topic. Your engagement and learning journey matter to me.
What's Next?
Stay tuned for more in-depth articles where we'll explore other exciting cloud projects and DevOps topics.
Let's Connect!
I'd love to hear your thoughts and experiences! Drop your comments below or connect with me on . Your feedback helps me create more valuable content for our tech community.
Happy Learning!
My name is Soumen Bhunia. This is my first blog. In this blog, I build and deploy my first Node.js app using Docker, hosted on an AWS EC2 instance, and connected to a MySQL database hosted via Amazon RDS
Technologies Used
- – JavaScript runtime to build the server-side app
- – For containerizing the Node.js app
- – Virtual server for running the Docker container
- – Managed MySQL database service
- – For access control to EC2 and RDS
Step 1: Create an RDS MySQL Instance
- Go to .
- Click Create Database.
- Choose:
- Engine type: MySQL
- Use case: Free Tier
- Under Settings:
- Set a DB instance identifier
- Master username: admin
- Master password: Set a secure password (avoid special characters like @, %, etc.)
- In Connectivity:
- Enable Public access =
(for development purposes) - Create a new VPC security group
- Add an inbound rule to allow MySQL/Aurora (port 3306) from Anywhere (0.0.0.0/0)
- Enable Public access =
After RDS is created, copy the endpoint/hostname — you'll use it to connect your app to the database.
Step 2: Launch and Configure an EC2 Instance
Go to .
Launch a new instance:
- Amazon Linux 2 AMI (Free Tier eligible)
- Choose t2.micro (Free Tier)
In Security Group, allow:
- HTTP (port 80) – for web traffic
- SSH (port 22) – for connecting to the instance
- Optional: Restrict access by IP for SSH
Once connected to EC2, run the following:
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -aG docker ec2-user
Important: Log out and log back in to activate Docker permissions for ec2-user.
Step 4: Run the Dockerized Node.js App
Pull the Docker image:
sudo docker pull philippaul/node-mysql-app:02
Then run your container, replacing the values with your actual RDS credentials:
docker run --rm -p 80:3000 \
-e DB_HOST="your-db-endpoint.rds.amazonaws.com" \
-e DB_USER="admin" \
-e DB_PASSWORD="your-db-password" \
-d philippaul/node-mysql-app:02
Your app should now be accessible at your EC2 public IP on port 80.
Web interface screenshot
Optional: Test the MySQL Connection
You can test connecting to the database from inside EC2 using a MySQL Docker client:
docker run -it --rm mysql:8.0 mysql \
-h your-db-endpoint.rds.amazonaws.com \
-u admin -p
Enter your password when prompted. If you connect successfully — your EC2 can talk to your RDS instance.
Wrapping Up
Thank you for investing your time in reading this article! I hope these insights have provided you with practical value and a clearer understanding of the topic. Your engagement and learning journey matter to me.
What's Next?
Stay tuned for more in-depth articles where we'll explore other exciting cloud projects and DevOps topics.
Let's Connect!
I'd love to hear your thoughts and experiences! Drop your comments below or connect with me on . Your feedback helps me create more valuable content for our tech community.
Happy Learning!