-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker (1).txt
110 lines (83 loc) · 2.75 KB
/
docker (1).txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Install WSL (if not already installed)
wsl --install
wsl --list --all
Enable Required Windows Features
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
# Install and run Ubuntu
wsl -d Ubuntu
# Verify Docker installation
docker --version # Check if Docker is already installed; if not, proceed with the next steps.
# Update the package list
sudo apt update
# Install dependencies
sudo apt install apt-transport-https ca-certificates curl software-properties-common
# Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Add Docker's stable repository
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update package list again
sudo apt update
# Install Docker Community Edition (CE)
sudo apt install docker-ce docker-ce-cli containerd.io -y
# Start Docker service
sudo service docker start
# Add your user to the Docker group (to avoid needing 'sudo' every time)
sudo usermod -aG docker $USER
# Apply group changes
newgrp docker
# Verify Docker installation
docker --version
INSTALL DOCKER COMPOSE
sudo apt install docker-compose -y
docker-compose --version # Verify installation
CREATE THE PROJECT DIRECTORY AND COMPOSE FILE
mkdir my-docker-project
cd my-docker-project
nano docker-compose.yml #write docker-compose.yml
version: '3.9'
services:
web:
image: nginx:latest
ports:
- "8080:80"
volumes:
- ./html:/usr/share/nginx/html
depends_on:
- db
db:
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: mydatabase
MYSQL_USER: myuser
MYSQL_PASSWORD: mypassword
volumes:
- db-data:/var/lib/mysql
volumes:
db-data: ==> ctr+o enter ctr+x
PREPARE CONTEXT FOR NGINX
mkdir html
nano html/index.html
<!DOCTYPE html>
<html>
<head>
<title>Docker Web Server</title>
</head>
<body>
<h1>Hello from Dockerized Nginx!</h1>
</body>
</html>
RUN THE APPLICATION
docker-compose up -d
VERIFY EVERYTHING
Access the application in your browser at http://localhost:8080.
Use docker ps to check running containers.
Inspect the database using a MySQL client if needed.
TAKE SCREENSHOTS
Take screenshots of the docker ps output, the docker-compose.yml file, and the browser displaying http://localhost:8080.
8. EXPORT YOUR FILES
Save all content (docker-compose.yml, index.html, and screenshots) in a .pdf file or archive them.
bash
Copy code
zip -r submission.zip docker-compose.yml html screenshots/