To launch Docker in Ec2 Instance and installing Webserver on Docker
To Launch An Instance in AWS ::
Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services (AWS) Cloud. Using Amazon EC2 eliminates your need to invest in hardware up front, so you can develop and deploy applications faster. You can use Amazon EC2 to launch as many or as few virtual servers as you need, configure security and networking, and manage storage. Amazon EC2 enables you to scale up or down to handle changes in requirements or spikes in popularity, reducing your need to forecast traffic.
▪ give name to your instance
▪ select ISO image to launch OS
▪ select the architecture
▪ select instance type
▪ Download the key pair
▪Do network settings
▪Do network settings
▪ configure storage
▪ select no.of instances to launch
▪ If you want read the summary for review
Then click on LAUNCH INSTANCE
To connect to the launched instance using SSH
First we need to give permission using chmod command
$ chmod 400 redhat-key.pem
Then using ssh connect to the instance
$ ssh -i "key_name" <user_name>@ <public_ip>
Recommended by LinkedIn
To Install Docker In EC-2 Instance
Docker makes development efficient and predictable,Docker takes away repetitive, mundane configuration tasks and is used throughout the development lifecycle for fast, easy and portable application development.
$ apt-get install docker.io
Docker needs root permission ,we can't directly run docker by using normal user privilages
Before going to install docker,first you need to update the instance by running the command
$ apt-get update
Then run again the command to install the docker,then docker will be installed in your instance,To check use the command $ docker images
To launch a container using Docker
$ docker run -it <image_name>:<tag>(optional)
We can use run cmd or pull cmd to download os image in docker
When we run the command . it by default after installing the image it uses that image and we enter into that container
Here we need to use -p option for port forwarding
To install Web Server in Container
$ apt install apache2
Run the above command To install web server in ubuntu.
To View From Web Browser
Enter the public ip of the instance you launched in AWS in the browser to see the web page you have written.
Thanks For Reading :)
Good work👍