Table of contents
- Steps involved to achieve this
- Step 1 : Clone git repo
- Step 2 : Build docker image and tag it
- Step 3 : Push image to the DockerHub
- Step 4 : Launch an EC2 instance of instace type "t2.micro" and open port 3000 in SG inbound rule
- Step 5 : Install docker on EC2 instance
- Step 6 : run docker run command [to run a container out docker image] to access the application
- YOUTUBE reference for this Demo
In this article we are going to understand how to deploy a Docker image into a AWS EC2 instance and access the application using EC2 instance public IP
Steps involved to achieve this
Clone git repo
build docker image
push docker image to the DockerHub
Launch an EC2 instance
Install Docker in EC2 instance
run docker run command [to run a container out docker image] to access the application
Step 1 : Clone git repo
use the below git clone command to download the git repo in to your local system
git clone https://github.com/jaswanthnasa/Nodejs-app-demo.git
Step 2 : Build docker image and tag it
use below command to build docker image
cd simple-nodejs-app
docker build -t sample-nodejs-app .
docker tag sample-nodejs-app <your-artifactory-repo-name>/sample-nodejs-app:v1
# docker tag sample-nodejs-app jas09563/sample-nodejs-app:v1
Step 3 : Push image to the DockerHub
docker push <your-dockerhub-repo-name>/sample-nodejs-app:v1
# docker push jas09563/sample-nodejs-app:v1
Step 4 : Launch an EC2 instance of instace type "t2.micro" and open port 3000 in SG inbound rule
Step 5 : Install docker on EC2 instance
sudo su
yum install docker -y
yum service docker start
Step 6 : run docker run command [to run a container out docker image] to access the application
docker run -d -p 3000:3000 jas09563/sample-nodejs-app:v1
access the application using Instance public ip
<public_ip>:3000