Hosting a Website In Docker Container And Managing It Using Docker Swarm.
Docker Swarm is a container orchestration engine, which means it allows users to manage multiple containers deployed on multiple hosts. One of the main advantages associated with running a docker bucket is the high level of availability offered to applications. Docker swarm consists of a master node along with many workers node. This master node is mostly helpful in managing and handling the resources among the worker node most efficiently. One of the major advantages of the docker swarm it has its own ingress load balancer and which does load balancing across many docker containers and hosts.
Docker Swarm Services :-
Docker swarm generally consists of two services which include :-
1. Replicated Services :: In this service docker swarm generally
replicates service containers by the user which is assigned
number in the master node and
deploy the containers into different
worker nodes.
2.Global services :: Global services work by using a master node to schedule a task for each available worker node that responds to service constraints and resource requests.
Docker Swarm Architecture:-
Steps To Host A Website In Docker Container And Managing It Using Docker Swarm.
1. Launch a 3 Ec2 instances with tags as master, worker-1 , worker-2.
Connect To Servers using
the third Party Applications such as Xshell and initialize
docker.
Command to initialize Docker is:- yum install docker* -y
.png)
Command to start docker is :- systemctl start docker.
3. Initialize Docker Swarm into your instances.
Command to initialize docker Swarm :- docker swarm init.
4. Attach the worker nodes to the master node.
.png)
Command:- (docker node ls ) gives info about each and every
worker node attach to master node through the help of docker
swarm.
write the docker file to carry out the following
functions. And Docker file should written into the VI
Editor.
.png)
Copy and run the same Docker file into the worker node's
as it will be helpful in building the image of the same
Docker Container into the worker node's also. Save the docker file into the VI Editor and run the
following to command to build the image of the docker container into the master node.
.png)
Run the Command docker service create --name app-server -p 80:80
appimage:1 : - This Command will create the
service containers using
the Replicated service provided by the Docker Swarm.
Launching the Elastic load balancer with DNS mapping using Route 53 and finally establishing a secure connection and configuring SSL using AWS Certificate Manager.
what is Elastic load balancer?
A load balancer serves as the single point of contact for clients. The load balancer distributes incoming application traffic across multiple targets, such as EC2 instances, in multiple Availability Zones. This increases the availability of your application. You add one or more listeners to your load balancer. A listener checks for connection requests from clients, using the protocol and port that you configure. The rules that you define for a listener determine how the load balancer routes requests to its registered targets.

2.
Name the load balancer as follows and select the vpc and subnets along
with create the target group to
which the traffic will route.

choose the target group created.
choose the target group created.
Also create a security group with ssh, http, https enabled in it while
creating a application load balancer. And paste the DNS of the load
balancer in the browser and you can see your website.
What is Route 53?
Amazon Route 53 is a highly available and scalable Domain Name System
(DNS) web service. Route 53 can be used to perform three main
functions in any combination: domain registration, DNS routing, and
health checking.
1. click on hosted zones to create a hosted zone.

Create record in Route 53.
After creating the records you have add the name server to name
server of your Domain Registrar.
You can get free domain from www.namecheap.com using your GitHub student pack.
After you Create the records in Route 53 then You can hit
https:// <your Domain Name>
in your Browser and you will find your website up and
running.
How to attach a SSL to your custom domain?
AWS Certificate Manager is a service that lets you easy deployment
public and private Secure Sockets Layer/Transport Layer Security
(SSL/TLS) certificates .
Search for the ACM (AWS CERTIFICATE MANAGER) and Click on
Request for Certificate And
then give your domain name and Request for certificate as
follows:-

After certificate issued click on the certificate Id And click on
create DNS record in Route 53.Then Add listeners to your load
balancer as follows:-


This listeners will redirect to port 443 always where SSL is
configured which will provide a secure connection to your
website.


Some important Concepts:-
Connection Draining:- When Connection Draining is enabled and configured,
the process of deregistering an instance from
an Elastic Load Balancer gains an additional
step. For the duration of the configured timeout, the load
balancer will allow existing, in-flight requests made to an
instance to complete, but it will not send any new requests
to the instance. During this time, the API will report the
status of the instance as In-service, along with a message
stating that “Instance deregistration currently in
progress.” Once the timeout is reached, any remaining
connections will be forcibly closed.
Create record in Route 53.
After creating the records you have add the name server to name
server of your Domain Registrar.
You can get free domain from www.namecheap.com using your GitHub student pack.
After you Create the records in Route 53 then You can hit
https:// <your Domain Name>
in your Browser and you will find your website up and
running.
How to attach a SSL to your custom domain?
AWS Certificate Manager is a service that lets you easy deployment
public and private Secure Sockets Layer/Transport Layer Security
(SSL/TLS) certificates .
Search for the ACM (AWS CERTIFICATE MANAGER) and Click on
Request for Certificate And
then give your domain name and Request for certificate as
follows:-
After certificate issued click on the certificate Id And click on
create DNS record in Route 53.Then Add listeners to your load
balancer as follows:-
This listeners will redirect to port 443 always where SSL is
configured which will provide a secure connection to your
website.
Some important Concepts:-
Connection Draining:- When Connection Draining is enabled and configured,
the process of deregistering an instance from
an Elastic Load Balancer gains an additional
step. For the duration of the configured timeout, the load
balancer will allow existing, in-flight requests made to an
instance to complete, but it will not send any new requests
to the instance. During this time, the API will report the
status of the instance as In-service, along with a message
stating that “Instance deregistration currently in
progress.” Once the timeout is reached, any remaining
connections will be forcibly closed.


Got to learn ....
ReplyDelete