1
+ Here's the updated ** Docker Assignment** with clear instructions for running Docker containers in each task:
2
+
3
+ ---
4
+
1
5
### ** Docker Assignment: Getting Started with Images and Containers**
2
6
3
7
#### ** Objective:**
@@ -8,9 +12,18 @@ Gain hands-on experience with Docker by pulling an image from Docker Hub, buildi
8
12
### ** Assignment Tasks**
9
13
10
14
#### ** Task 1: Pull an Image from Docker Hub**
11
- 1 . Use the ` docker pull ` command to download the official ** nginx** image from Docker Hub.
12
- 2 . Verify the image is available locally using the ` docker images ` command.
13
- 3 . Run a container from the ** nginx** image and expose it on port 8080 of your host.
15
+ 1 . Use the ` docker pull ` command to download the official ** nginx** image from Docker Hub:
16
+ ``` bash
17
+ docker pull nginx
18
+ ```
19
+ 2 . Verify the image is available locally using the ` docker images ` command:
20
+ ``` bash
21
+ docker images
22
+ ```
23
+ 3 . Run a container from the ** nginx** image and expose it on port 8080:
24
+ ``` bash
25
+ docker run -d -p 8080:80 nginx
26
+ ```
14
27
4 . Open a web browser and visit ` http://localhost:8080 ` to confirm nginx is running.
15
28
16
29
---
@@ -22,23 +35,42 @@ Gain hands-on experience with Docker by pulling an image from Docker Hub, buildi
22
35
FROM nginx:latest
23
36
COPY index.html /usr/share/nginx/html/index.html
24
37
```
25
- 3 . Add a custom ` index.html ` file to the same directory with personalized content (e.g., "Welcome to my custom nginx!").
38
+ 3 . Add a custom ` index.html ` file to the same directory. Use the following content for ` index.html ` :
39
+ ``` html
40
+ <!DOCTYPE html>
41
+ <html lang =" en" >
42
+ <head >
43
+ <meta charset =" UTF-8" >
44
+ <meta name =" viewport" content =" width=device-width, initial-scale=1.0" >
45
+ <title >Custom Nginx</title >
46
+ </head >
47
+ <body >
48
+ <h1 >Welcome to My Custom Nginx!</h1 >
49
+ <p >This page is served from a custom Docker image built by you.</p >
50
+ </body >
51
+ </html >
52
+ ```
26
53
4 . Build a new Docker image with the command:
27
54
``` bash
28
55
docker build -t custom-nginx .
29
56
```
30
- 5 . Verify the image is built using ` docker images ` .
31
57
32
58
---
33
59
34
60
#### ** Task 3: Run a Container from the Custom Image**
35
- 1 . Run a container using the newly built ` custom-nginx ` image and expose it on port 9090.
61
+ 1 . Run a container using the newly built ` custom-nginx ` image and expose it on port 9090:
62
+ ``` bash
63
+ docker run -d -p 9090:80 custom-nginx
64
+ ```
36
65
2 . Open a web browser and visit ` http://localhost:9090 ` to verify the custom nginx page is displayed.
37
66
38
67
---
39
68
40
69
#### ** Task 4: Push the Image to Docker Hub**
41
- 1 . Log in to Docker Hub using the ` docker login ` command.
70
+ 1 . Log in to Docker Hub using the ` docker login ` command:
71
+ ``` bash
72
+ docker login
73
+ ```
42
74
2 . Tag your custom image to match your Docker Hub repository:
43
75
``` bash
44
76
docker tag custom-nginx < your-dockerhub-username> /custom-nginx
@@ -63,8 +95,8 @@ Gain hands-on experience with Docker by pulling an image from Docker Hub, buildi
63
95
64
96
### ** Evaluation Criteria**
65
97
- Proper execution of all commands and tasks.
66
- - Successful creation and display of a custom web page.
98
+ - Successful creation and display of the custom web page.
67
99
- Correctly tagged and pushed image to Docker Hub.
68
100
- Clarity and completeness of screenshots and documentation.
69
101
70
- This assignment combines basic Docker operations with hands-on practice to reinforce key concepts.
102
+ Let me know if you need further assistance or clarifications!
0 commit comments