Dockerfile >Docker Image > Docker Container | Beginners Hands-On | Step by Step

preview_player
Показать описание
STEPS
Create a Dockerfile
Add instructions in Dockerfile to create Docker image
Run Dockerfile to create Docker image
Run Docker image to create Docker container
Access the application running in Docker container

Dockerfile > Docker Image > Docker Container > Access the App

Step 1 - Create a new directory *mkdir myapp*
*cd myapp*

Step 3 - Create a file named Dockerfile *touch Dockerfile*

Step 4 - Open the "Dockerfile" file in a text editor and add the following lines:

FROM nginx

This Dockerfile defines a new Docker image that
- uses the official nginx image as a base

A Dockerfile is a text file with instructions to build a Docker Image
When we run a Dockerfile, Docker image is created
When we run the docker image, containers are created

Step 5 - Start docker & Build docker image from dockerfile
*docker build -t myapp .*
This command builds a new Docker image with the tag "myapp" using the Dockerfile in the current directory.

Step 6 - Run docker container from the image
*docker run -p 8080:80 myapp*
This tells Docker to run the myapp container and map port 8080 on your local machine to port 80 inside the container

Step 7 - Access the app

If you are using AWS EC2 Linux, you will need to make sure that the security group for your AWS Linux instance allows inbound traffic on port 8080 (or whichever port you chose to map to port 80 inside the container).

Here's how to modify the security group:

In the navigation pane, choose "Instances".
Select your AWS Linux instance in the list.
Choose the "Security" tab in the bottom pane.
Select the security group associated with your instance and choose the "Edit inbound rules" button.
Add a new rule with the following settings:
Type: "Custom TCP Rule"
Protocol: "TCP"
Port Range: "8080" (or whichever port you chose to map to port 80 inside the container)
Source: "0.0.0.0/0" (or restrict the source IP address range to your specific needs)
After modifying the security group, you should be able to access the web page served by your Docker container by navigating to http://<Public_IP_of_your_instance>:8080 in a web browser.

▬▬▬▬▬▬▬

Every Like & Subscription gives me great motivation to keep working for you
You can support my mission for education by sharing this knowledge and helping as many people as you can

If my work has helped you, consider helping any animal near you, in any way you can

Never Stop Learning
Raghav Pal

▬▬▬▬ USEFUL LINKS ▬▬▬▬

▬▬ CI | CD | DEVOPS ▬▬

▬▬ API TESTING ▬▬

▬▬ PERFORMANCE TESTING ▬▬

Dockerfile Tutorial for Beginners
Creating a Docker Image: Step-by-Step Guide
Hands-on Docker Container Creation for Beginners
How to Build a Docker Image from Scratch
Dockerfile Basics: A Complete Guide
Dockerfile and Docker Image Creation for Beginners
Beginner's Guide to Building a Docker Container from a Dockerfile
Docker Image Creation: A Comprehensive Tutorial
Creating Your First Docker Container: A Beginner's Hands-On Guide
Step-by-Step Guide to Building Docker Images and Containers for Beginners


Рекомендации по теме
Комментарии
Автор

Thanks Raghav, your way of explanation is simple and easy to understand. Thank you so much for your valuable contributions to people like me who are learning from basics.

sangativamsikrishna
Автор

A straight-to-the-point tutorial! Thanks for your service in the spirit of betterment. Your tutorial is a great testament to the power of sharing knowledge, and helping others to gain an edge.

issa_coder
Автор

This is so far the best video on youtube with simple and straight to the point explanation. Thank you sir. I have subscribed

djfago
Автор

This is amazing. I was trying EC2 instance first time to have docker run on it and this video made all my concepts very clear. Thanks for covering the security groups.

niharikaverma
Автор

Wonderfully concise and mentioning the why behind each choice is the difference between valuable and garbage training content. Thank you!

pensiveidea
Автор

I had no idea about Dockerfile. Your session gave me a big support and confidence to write a dockerfile. Thank you very much.

preethic
Автор

Very good video that goes through all steps. Better than some professional teaching videos that do not explain details. Thank you, good job!

rezasaffarpour
Автор

Thank you so much sir...🙂🙂
Your way of explaining is too good .. anyone can understand these lessons (without IT background also)

sravani
Автор

Randomly I got this video for Docker file, the way of teaching and pace of teaching is really good and appreciable. Thank you for such content I am following you from now and will see all the required videos on devops...

TravellingSquad
Автор

Thank you for another perfectly explained video.... and thank you for keeping it simple and explaining even the small details.. some of us need that. Kudos to you!

pattyallbritton
Автор

Thanks Raghav, your explanation helped me understand way better.

brandoncazares
Автор

Raghav, you're amazing. You've just saved my day. Thank you very much for that beneficial content! Keep up the amazing work you've been delivering.

servais-fridompandi
Автор

Explained in a very simple language. Thank you.

rohitwattamwar
Автор

Thank you, Raghav. This was perfect for me! You were very clear and thorough. Great job!

cebundy
Автор

Sir. Its really helpful for the community..!!! 👏 👏 Especially for the people like me who are slow learners

rekhamallikarjun
Автор

Amazing! so well explained in a simple language for beginners like me to fully understand.

laurenngerem
Автор

Thank you very much for this video Raghav. It was very great to understand and learn. Not even GUVI classes taking this much effective classes.

bodhidharman
Автор

Clear and straight to the point. Thank you! 😊

bariborsaturday
Автор

Thanks, it really helps me to understand better the whole process of docker image and container👍

akhror-oshie
Автор

Great Playlist, Thanks Raghav your explanation is very good and really helpful to understand. Thanks a lot for this.

tarunkumargupta