Want to make storage of your website running on Docker persistent or to share same storage to any regions of AWS ?

Want to make storage of your website running on Docker persistent or to share same storage to any regions of AWS ?

No alt text provided for this image

Here my main aim is to make the storage of my website running on Docker in an instance in AWS and also to share the same storage to any regions of the AWS without any loss of data.

Step 1: Create a instance and login via SSH using Putty.

Here I am launching an instance named linux_os with linux AMI .

No alt text provided for this image

Now to access this created O.S we need to connect by SSH protocol. For this I am using Putty ( PuTTY is an SSH ).But putty accept .ppk format key but I have created .pem format , so we have to convert it for this I used puttygen. Click load > search for key . And give name either same or different name.

No alt text provided for this image

Click Yes and select Save private key. Login with ec2-user@IP. IP of instance to be used. Click ope and you'll be logined to the linux_os.

No alt text provided for this image
#sudo su - root                            ( to get root power )
#yum install docker -y                     ( install docker )
# service docker start                     ( start docker )
#chkconfig docker on
#docker pull vimal13/apache-webserver-php  ( Pull docker image )

To let anyone view your website of from your linux O.S set inbounds to TCP with port (I used 81 ).

No alt text provided for this image

Step 2: Create volume (EBS) and attach to this linux_os .

This new created volume will be our external hard disk or as a pendrive which will store data of OS. Now attach this storage ( pendrive1 ) to running instance ( linux_os )

No alt text provided for this image
No alt text provided for this image

Hence external storage is created .

Now 3 steps to be followed as it is an Block Storage.

1. Partition of hard disk.
    
   # fdisk -l            ( list of hard disks )
   # fdisk /dev/xvdf1    ( go inside this hard disk )
   # n                   ( To create partition )
   # w                   ( To save )
2. Format the hard disk.
   # mkfs.ext4 /dev/xvdf1 

3. Mount.
   # mkdir /myweb
   # mount /dev/xvdf1 /myweb    ( To mount external hard disk to /myweb )
   # df -h                      ( To view the status )

No alt text provided for this image
No alt text provided for this image

Now my external hard disk is connected to /myweb folder. So any data stored in this folder will be copied same to this storage.

Step 3: Launch the container with apache webserver and mount.a

Now launch the container with docker image which has apache-webserver and mount /myweb to /var/www/html with port any port say 81.

Now /myweb will act as a storage of /var/www/html and previously we mounted /myweb to pendrive1( /dev/xvdf1 ) . Hence storage of wesite will be stored to pendrive1.

So, any data stored in /myweb will be stored in webserver running on docker (/var/www/html location). And we can view the website with IP of instance with port 81 .

No alt text provided for this image
No alt text provided for this image

Hence storage of website is persistent. If you terminate your docker container or terminate your O.S , data is stored safely on external hard disk ( pendrive1 ).

Rollback :

If you want create backup of your storage at a particular point of time in past we can save that storage using Snapshots . Click Action and create snapshot.

No alt text provided for this image

Now snapshot can be created at different point of time in order to retrive or Rollback data at any point of time.

No alt text provided for this image

From this snapshot we can :

  1. Create Volume and can attach to any new O.S .
No alt text provided for this image

2. We can copy this snapshot to any other regions of AWS globally.

No alt text provided for this image

Here I have copied to Singapore region . Now I can create volume of this snapshot and attach to new O.S with same data .

No alt text provided for this image

Hence , this is a great use-case of docker and AWS with great use of snapshot to create backup .

要查看或添加评论,请登录

Prashant Verma的更多文章

  • AWS EKS

    AWS EKS

    Amazon Elastic Kubernetes Service (Amazon EKS) is a fully managed Kubernetes service. Amazon Elastic File System…

  • Groovy script in Jenkins

    Groovy script in Jenkins

    In this article I will host website on kubernetes using Groovy script in Jenkins from docker image. Whole process will…

  • Prometheus & Grafana on Kubernetes

    Prometheus & Grafana on Kubernetes

    In this article I'll deploy Prometheus and Grafana on Pods in Kubernetes with : PVC ( for persistent storage ) SVC (…

    2 条评论
  • Rolling Updates in Kubernetes using Jenkins with Zero downtime.

    Rolling Updates in Kubernetes using Jenkins with Zero downtime.

    Reasons why need Rolling updates ? 1. Updating an application .

    2 条评论
  • Code Interpretation with Jenkins on Kubernetes

    Code Interpretation with Jenkins on Kubernetes

    In this article I will deploy Jenkins pods in kubernetes with SVC , PVC, Scaling support , which will execute code from…

  • Terraform to host website in AWS .

    Terraform to host website in AWS .

    Terraform helps you build , change , terminate whole infrastructure in single go. Just run the file coded in…

  • Code Interpreter using Jenkins

    Code Interpreter using Jenkins

    Depending upon the code commited by developer in Github Jenkins will download the code and execute it based upon the…

  • Kubernetes and Jenkins Integration

    Kubernetes and Jenkins Integration

    Some of us might facing issues in integrating K8s and Jenkins so , follow these steps to setup an environment for…

  • DevOps : Production & Testing Automation | Docker |Git | Jenkins |Linux

    DevOps : Production & Testing Automation | Docker |Git | Jenkins |Linux

    CODE: Aim : As soon as a developer makes some changes (or commits in Git for the website) it is automatically send to…

社区洞察

其他会员也浏览了