filmov
tv
Dockerfile >Docker Image > Docker Container | Beginners Hands-On | Step by Step
Показать описание
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
—
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
—
Комментарии