Skip to content

Commit 23ce397

Browse files
authored
Update README.md
1 parent 8a15c9f commit 23ce397

File tree

1 file changed

+64
-47
lines changed

1 file changed

+64
-47
lines changed

README.md

Lines changed: 64 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -26,97 +26,112 @@ The main goal of this exercise was to set up a simple web server inside a Docker
2626
1. **Creating the Dockerfile**: I started by creating a `Dockerfile` to configure the web server. The Dockerfile uses the official **Nginx** image, and it exposes the application on port `8002`.
2727

2828
```Dockerfile
29-
# Use the official Nginx image
29+
# Nginx image in the Docker Hub
3030
FROM nginx:latest
31-
32-
# Copy custom index.html to the container's web directory
33-
COPY index.html /usr/share/nginx/html/index.html
34-
35-
# Expose port 8002 for the web server
31+
# Nginx configuration
32+
COPY nginx/nginx.conf /etc/nginx/nginx.conf
33+
# Exposing the port 8002
3634
EXPOSE 8002
37-
```
38-
35+
# Health Check
36+
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
37+
CMD curl -f http://localhost:8002/ || exit 1
38+
# default command to run Nginx
39+
CMD ["nginx", "-g", "daemon off;"]
40+
```
3941
2. **Building and Running the Container**:
4042
After writing the Dockerfile, I built the Docker image using the following command:
4143
```bash
42-
docker build -t my-nginx-app .
44+
docker build -t terra-simple-nginx-server .
4345
```
4446
And ran the container:
4547
```bash
46-
docker run -d -p 8002:80 my-nginx-app
48+
docker run -d -p 8002:80 terra-simple-nginx-server
4749
```
48-
49-
Once this was set up, the web server was live and accessible at `http://localhost:8002`.
50+
The web server was live and accessible at `http://localhost:8002`. As shown in the Screenshort [https://github.com/Timoo20/info-sec-devops-devsecops-terra/blob/main/images-screenshots/Validating%20in%20localhost.png]
5051

5152
---
53+
### Health Check
5254

53-
### Health Check Configuration
54-
55-
A health check is essential to ensure that the container is up and running correctly. To add this, I configured a health check in the Dockerfile, which pings the root path of the web server every 30 seconds to ensure it is alive.
55+
A health check is important as it ensures that the container is up and running perfectly; as expected. To achieve this, I configured a health check in the Dockerfile that pings the root path of the web server every 30 seconds to ensure it is alive.
5656

5757
```Dockerfile
5858
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
5959
CMD curl --silent --fail http://localhost:8002/ || exit 1
6060
```
61-
62-
If the web server does not respond successfully within the set parameters, Docker will consider the container "unhealthy."
61+
[As shown in the screenshort](https://github.com/Timoo20/info-sec-devops-devsecops-terra/blob/main/images-screenshots/Health-Container-Status.png)
62+
Incase the web server does not respond successfully within the configured param, then Docker will consider the container "UNHEALTHY."
6363

6464
---
6565

6666
### Troubleshooting Docker Health Checks
6767

68-
During my setup, I encountered an issue where the health check was consistently failing. Here’s how I tackled the issue:
68+
If I encounter issues with Docker health checks, I would take to troubleshoot the problem by:
6969

70-
1. **Check the Logs**: First, I looked at the container logs using `docker logs <container_id>` to see if there were any clues about errors or misconfigurations.
71-
72-
2. **Examine the Health Check Status**: Using the command `docker inspect --format='{{json .State.Health}}' <container_id>`, I was able to inspect the health check status and pinpoint the issue.
70+
1. **Checking the Logs**:
71+
First, I would check the container logs to gather any clues about errors or misconfigurations that might be affecting the health check. For example, I ran the following command for my container:
72+
```bash
73+
docker logs 350df94ecfdc
74+
---
75+
The logs showed the server returning the expected **"Hey! This is hello from Terra Software Company. Welcome to your Nginx server" **message, which confirmed the web server was functioning correctly.
7376

74-
3. **Test the Web Server Directly**: To rule out potential networking issues, I accessed the container directly using `docker exec` and tested the server internally with `curl`.
77+
2. **Examine the Health Check Status:**
7578

76-
4. **Increase Timeout & Retry Settings**: Finally, I tweaked the health check settings, such as increasing the timeout and retry count, which helped the container pass the health check successfully.
79+
```bash
80+
docker inspect --format='{{json .State.Health}}' 350df94ecfdc
81+
---
82+
83+
When I executed the command, it showed that it is in healthy [As shown in the screenshort](https://github.com/Timoo20/info-sec-devops-devsecops-terra/blob/main/images-screenshots/Health-Container-Status.png) ; hence confirming the container was in good health.
7784
78-
---
7985
80-
## Scenario-Based Troubleshooting
86+
3. **Teting in web server directly:**
87+
88+
I access the container directly and test the web server inside using curl. This helps in fixing network issues.
89+
90+
91+
4. **Increasing the Timeout & Retry Configuration::**
92+
93+
I would change the health params to fix the issue. For example; instead of 5 seconds in the timeout onfiguration, I would consider extending it to about 10 Seconds.
94+
95+
96+
97+
## PART 2
8198
8299
### Scenario 1: Failing Health Checks in Docker
83100
84-
Sometimes, health checks can fail due to various reasons, like misconfigurations or network issues. In my case, the Docker health check was failing.
101+
Health checks can fail because of misconfigurations or maybe because of network issues. In my case, the Docker health check was successful. Incase Docker fails, i would have considered:
85102
86-
#### Here's how I solved it:
87-
1. **Inspect the Health Check Output**: I started by using `docker inspect` to get more details about the health check status, which pointed out that the issue was a time-out from the health check ping.
103+
1. **Inspecting the Health Checks**: I would utilize `docker inspect` to get finer details about the health status.
88104
89-
2. **Check the Web Server Logs**: The logs revealed that Nginx was not fully loading the content due to a missing file.
105+
2. **Checking the Web Server Logs**: I would keenly check the server logs.
90106
91-
3. **Adjust the Health Check Parameters**: After resolving the file issue, I adjusted the health check’s timeout and retries to give the container a little more time to respond.
92-
93-
4. **Rebuild the Container**: Once the changes were made, I rebuilt the Docker container and ran it again. This time, the health check passed, confirming the issue was resolved.
107+
3. **Fine tuning the the Health Check Params**: I would fine tune the health params to fix the issue. For example; instead of 5 seconds in the timeout onfiguration, I would consider extending it to about 10 Seconds.
108+
109+
4. **Rebuilding the Container**: I will rebuilt the container and ran it again.
94110
95111
---
96112
97113
### Scenario 2: Nginx Ingress Not Accessible
98114
99-
In this scenario, I exposed a service via **Nginx Ingress**, but it wasn’t accessible over the internet. Here’s how I approached the troubleshooting:
115+
In this scenario, this is how I would approach the troubleshooting:
100116
101-
1. **Check the Ingress Controller**: I first made sure that the **Nginx Ingress Controller** was properly set up and running in my Kubernetes cluster by using `kubectl get pods -n ingress-nginx`.
117+
1. **Checking the Ingress Controller**: I would first assess the Ingress Controller to ensure that it is up and running.
102118
103-
2. **Inspect the Ingress Resource**: I verified that the **Ingress Resource** was configured correctly with the correct **host** and **service** details.
119+
2. **Inspecting the Ingress Resource**: I would keenly verify the ingress Resource; to ensure that it is properly correctly with the correct **service** and **host** details.
104120
105-
3. **DNS and Routing**: Next, I checked if the DNS settings were correctly pointing to the IP address of the Ingress controller.
121+
3. **DNS checking**: I would check the DNS settings to ensure that they are correctly pointing to the exact Ingress controller - IP address.
106122
107-
4. **Firewall Rules**: I made sure that the relevant ports (80/443) were open in the cloud provider’s security group or firewall.
123+
4. **Firewall Rules**: I would check if the ports Port 80/443 were open in the cloud provider’s security group or firewall.
108124
109-
5. **Nginx Logs**: Finally, I looked at the logs of the **Nginx Ingress Controller** to check for any issues in routing or configuration.
125+
5. **Nginx Logs**: Finally, I would look at the logs to check for any issues in routing or configuration.
110126
111127
---
112128
113129
## Tech Stack Used
114130
115-
- **Docker**: To build and run the containerized web application.
116-
- **Nginx**: Used as the web server to serve the content.
117-
- **Kubernetes & Ingress**: To manage and expose services in a Kubernetes environment.
118-
- **Curl & Wget**: For testing service health and availability.
119-
- **YAML & Dockerfiles**: For configuration management and defining services.
131+
- **Docker**: To build and run the terra-simple-nginx-server application.
132+
- **Nginx**: Utilized as the web server to serve the content.
133+
- **Curl**: For testing service health and availability.
134+
- **Yaml & Dockerfiles**: For configuration management.
120135
121136
---
122137
@@ -125,19 +140,21 @@ In this scenario, I exposed a service via **Nginx Ingress**, but it wasn’t acc
125140
To get started with this project, you'll need:
126141
127142
- **Docker** installed on your local machine or VM.
128-
- **Kubernetes** (optional, for the Nginx Ingress exercise).
129143
- Access to a terminal to run the commands and build the containers.
130144
131145
---
132146
## About Me & Contact
133147
134-
I'm a **Cybersecurity/DevSecOps/DevOps professional** passionate about building secure, scalable, and efficient applications. I focus on bridging the gap between development and security to create seamless solutions that are both effective and safe.
148+
I'm a **Developer/Cybersecurity/DevSecOps/DevOps professional** passionate about building secure, scalable, and efficient applications. I focus on bridging the gap between development and security to create seamless solutions that are both effective and safe.
135149
136150
If you want to connect or have any questions about this repository or the exercises, feel free to reach out!
137151
138152
- **Email**: [[email protected]](mailto:[email protected])
139-
- **LinkedIn**: [Tim Murkomen](https://www.linkedin.com/in/timoo20//)
153+
- **LinkedIn**: [Tim Murkomen](https://www.linkedin.com/in/timoo20/)
140154
---
141155
## LICENCE
142156
**License**: This project is Licensed under a Tim Murkomen Custom License by Tim Murkomen - Here is the Link [Custom Licence](https://github.com/Timoo20/info-sec-devops-devsecops-terra/blob/main/LICENSE)
143-
```
157+
158+
---
159+
Contributor: [Tim Murkomen](https://github.com/Timoo20)
160+
---

0 commit comments

Comments
 (0)