-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathdocker-commands.html
More file actions
299 lines (278 loc) · 21.3 KB
/
docker-commands.html
File metadata and controls
299 lines (278 loc) · 21.3 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="images/logo.png">
<link rel="apple-touch-icon" href="images/logo.png">
<title>Docker Commands - DevDunia</title>
<meta name="description" content="Docker commands cheat sheet with examples. Essential Docker commands for containerization, images, and orchestration.">
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="sidebar.css">
<style>
body {
background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}
</style>
</head>
<body class="min-h-screen">
<!-- Background: Consistent Subtle Dark Gradient -->
<div class="fixed inset-0 -z-10 bg-gradient-to-br from-gray-900 via-slate-900 to-gray-900"></div>
<!-- Sidebar Container -->
<div id="sidebar-container"></div>
<!-- Main Content -->
<div class="main-content">
<div class="relative z-10 container mx-auto px-4 pt-16 pb-24 sm:px-6 lg:px-8">
<!-- Header -->
<div class="text-center mb-8">
<h1 class="text-3xl sm:text-4xl font-bold mb-4 tracking-tight
text-transparent bg-clip-text bg-gradient-to-r from-emerald-400 to-teal-500">
Docker Commands
</h1>
<p class="text-lg text-gray-400 max-w-2xl mx-auto">
Essential Docker commands for containerization, images, and orchestration. Copy commands with one click.
</p>
</div>
<!-- Main Content -->
<div class="max-w-6xl mx-auto">
<!-- Getting Started -->
<div class="mb-8">
<h2 class="text-2xl font-semibold text-white mb-6">Getting Started</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">Run Container</h3>
<button class="text-blue-400 hover:text-blue-300" onclick="copyCommand('docker run -d -p 80:80 nginx')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker run -d -p 80:80 nginx</code>
<p class="text-gray-400 text-xs mt-1">Run nginx in detached mode on port 80</p>
</div>
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">Interactive Container</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker run -it ubuntu bash')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker run -it ubuntu bash</code>
<p class="text-gray-400 text-xs mt-1">Run Ubuntu container with interactive bash</p>
</div>
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">List Containers</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker ps')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker ps</code>
<p class="text-gray-400 text-xs mt-1">List running containers</p>
</div>
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">List All Containers</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker ps -a')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker ps -a</code>
<p class="text-gray-400 text-xs mt-1">List all containers (including stopped)</p>
</div>
</div>
</div>
<!-- Container Management -->
<div class="mb-8">
<h2 class="text-2xl font-semibold text-white mb-6">Container Management</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">Stop Container</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker stop <container_id>')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker stop <container_id></code>
<p class="text-gray-400 text-xs mt-1">Stop a running container</p>
</div>
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">Remove Container</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker rm <container_id>')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker rm <container_id></code>
<p class="text-gray-400 text-xs mt-1">Remove a container</p>
</div>
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">Execute Command</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker exec -it <container_id> bash')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker exec -it <container_id> bash</code>
<p class="text-gray-400 text-xs mt-1">Execute bash in running container</p>
</div>
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">View Logs</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker logs <container_id>')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker logs <container_id></code>
<p class="text-gray-400 text-xs mt-1">View container logs</p>
</div>
</div>
</div>
<!-- Image Management -->
<div class="mb-8">
<h2 class="text-2xl font-semibold text-white mb-6">Image Management</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">List Images</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker images')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker images</code>
<p class="text-gray-400 text-xs mt-1">List all Docker images</p>
</div>
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">Pull Image</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker pull nginx')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker pull nginx</code>
<p class="text-gray-400 text-xs mt-1">Download image from registry</p>
</div>
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">Build Image</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker build -t myapp .')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker build -t myapp .</code>
<p class="text-gray-400 text-xs mt-1">Build image from Dockerfile</p>
</div>
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">Remove Image</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker rmi <image_id>')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker rmi <image_id></code>
<p class="text-gray-400 text-xs mt-1">Remove Docker image</p>
</div>
</div>
</div>
<!-- Docker Compose -->
<div class="mb-8">
<h2 class="text-2xl font-semibold text-white mb-6">Docker Compose</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">Start Services</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker-compose up')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker-compose up</code>
<p class="text-gray-400 text-xs mt-1">Start all services</p>
</div>
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">Start in Background</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker-compose up -d')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker-compose up -d</code>
<p class="text-gray-400 text-xs mt-1">Start services in detached mode</p>
</div>
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">Stop Services</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker-compose down')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker-compose down</code>
<p class="text-gray-400 text-xs mt-1">Stop and remove services</p>
</div>
<div class="bg-slate-800/70 backdrop-blur-md rounded-lg shadow-lg border border-slate-700/60 p-4">
<div class="flex items-center justify-between mb-2">
<h3 class="text-white font-medium">View Logs</h3>
<button class=" text-blue-400 hover:text-blue-300" onclick="copyCommand('docker-compose logs')">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
</button>
</div>
<code class="text-green-400 text-sm">docker-compose logs</code>
<p class="text-gray-400 text-xs mt-1">View logs from all services</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Sidebar Scripts -->
<script src="sidebar-include.js"></script>
<script src="sidebar.js"></script>
<script>
function copyCommand(command) {
navigator.clipboard.writeText(command).then(() => {
// Show feedback
const button = event.target.closest('button');
const originalHTML = button.innerHTML;
button.innerHTML = '<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg>';
button.classList.add('text-green-400');
setTimeout(() => {
button.innerHTML = originalHTML;
button.classList.remove('text-green-400');
}, 2000);
}).catch(err => {
console.error('Failed to copy: ', err);
});
}
</script>
</body>
</html>