Dockerfile >Docker Image > Docker Container | Beginners Hands-On | Step by Step
🔥 All Free Tutorials – https://AutomationStepByStep.com/
Last session https://youtu.be/UgTt8qOsgEU
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 2 – Create a file called “index.html” *echo “Hello, world!” > index.html*
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
COPY index.html /usr/share/nginx/html
This Dockerfile defines a new Docker image that
– uses the official nginx image as a base
– then copy the index.html file to the appropriate location in the image
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
Open a web browser and navigate to http://localhost:8080 to see the “Hello, world!” message displayed in your web browser.
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:
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
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 ▬▬▬▬
Ask Raghav – https://bit.ly/2CoJGWf
Shorts Eng – https://bit.ly/3H9bifV
Shorts Hindi – https://bit.ly/3XY7XqN
GitHub Repositories – https://github.com/Raghav-Pal
Udemy Discounts – https://automationstepbystep.com/udemy-discounts/
Stories – https://automationstepbystep.com/stories/
▬▬ CI | CD | DEVOPS ▬▬
Jenkins Beginner – https://bit.ly/2MIn8EC
Jenkins Tips & Trick – https://bit.ly/2LRt6xC
Docker – https://bit.ly/2MInnzx
Jenkinsfile – https://bit.ly/3JSMSZ7
Kubernetes – http://bit.ly/2MJIlMK
▬▬ API TESTING ▬▬
Web Services (API) – https://bit.ly/2MGafL7
SoapUI – https://bit.ly/2MGahmd
Postman 2022 – https://bit.ly/3JWm4qX
Rest Assured – https://bit.ly/3zUdhRD
Karate API Testing – https://bit.ly/3w3H5Ku
JMeter API Testing – https://bit.ly/3AgVPar
Katalon Studio API Testing – https://bit.ly/2BwuCTN
API Mocking – https://bit.ly/3bYPsjS
▬▬ PERFORMANCE TESTING ▬▬
JMeter Beginner – https://bit.ly/2oBbtIU
Gatling – https://bit.ly/3QrWfkV
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
—
by Automation Step by Step
linux web server
please put a video on docker-compose
I had no idea about Dockerfile. Your session gave me a big support and confidence to write a dockerfile. Thank you very much.
I tried to build the image it shows access denied fir nginix
Great tutorial for beginners
Really good explanation and i got a clear picture of the docker topic
Amazing! so well explained in a simple language for beginners like me to fully understand.
How would i access your helloword from my pc? Or It's not possible. I am new to docker.
Thanks for the explanation! I am working on the applicable where it will automatically open the reports after my tests but when creating pipeline through dockers it's opened So I have copied the results of html file created from docker image to local instance.
Now my question how to open the html content which copied from docker image using docker run
So crystal clear
your teaching was super sir and how to write playbook in ansible make one vedieo sir
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…
This is so far the best video on youtube with simple and straight to the point explanation. Thank you sir. I have subscribed
An acronym for some of the most commonly used instructions in a Dockerfile is A WELSH CAFE COURSE.
A – ADD
W – WORKDIR
E – EXPOSE
L – LABEL
S – SHELL
H – HEALTHCHECK
C – CMD
A – ARG
F – FROM
E – ENV
C – COPY
O – ONBUILD
U – USER
R – RUN
S – STOPSIGNAL
E – ENTRYPOINT
I have tried the same in Azure and getting "The site cann't be reached' error. Any help appreciated.
Thank you
How if docker is not running
No any confusion, Easy to learn content. Thanks.
Thanks Raghav, your explanation helped me understand way better.
Amazing docker presentation – especially how it can be linked to azure
Show docker multistage build
This is such a wonderful video. I followed along with you but i stopped step #5 because while running the docker build -t myapp i got errors. I think it could because i am using my work laptop. Then i tried using environmental variables for proxy still i get error. Can you please help
Sir!!!!!!!!!thankyou 😊😊😊😊
This was really helpful and well explain>
Simple as it can be, loved it. However, I find it kind of funny that you app was working on port 80, even though there wasn't any rule in your security group.
Nice explanation
worked perfectly thanks so much
from docker build nothing works [root@ip-172-31-3-46 myapp]# docker build -t myapp . bash: docker: command not found
Great Playlist, Thanks Raghav your explanation is very good and really helpful to understand. Thanks a lot for this.
dockerfile add line below:
EXPOSE 80
Sir. Its really helpful for the community..!!! 👏 👏 Especially for the people like me who are slow learners
I have a basic doubt if anyone can help… why do you even need to create a docker image for a .html file? if you create it here on a Linux EC2 machin and install it on a windows machine as it is… without creating a docker container… will it not work?
Can we use multiple os in same docker image
Why did u use the path /use/share/nginx/html ,,is that any specific path,where did we got to know that path
Very good video that goes through all steps. Better than some professional teaching videos that do not explain details. Thank you, good job!
Very nice & Informative