├── README.md
└── cheats.json
/README.md:
--------------------------------------------------------------------------------
1 | # docker_cheat_sheet_data
2 | docker cheat data for [dockercheatsheet.com](https://dockercheatsheet.com)
3 |
4 | Pull Requests Welcome
5 |
--------------------------------------------------------------------------------
/cheats.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "desc": "Create and run containers in the foreground",
4 | "cat": "Compose",
5 | "keywords": [
6 | "start containers",
7 | "run containers"
8 | ],
9 | "shell": [
10 | "docker compose up"
11 | ]
12 | },
13 | {
14 | "desc": "Create and run containers in the background",
15 | "cat": "Compose",
16 | "keywords": [
17 | "start containers",
18 | "run containers"
19 | ],
20 | "shell": [
21 | "docker compose up -d"
22 | ]
23 | },
24 | {
25 | "desc": "List running containers",
26 | "cat": "Compose",
27 | "keywords": [
28 | "list containers",
29 | "show containers"
30 | ],
31 | "shell": [
32 | "docker compose ps"
33 | ]
34 | },
35 | {
36 | "desc": "List all containers",
37 | "cat": "Compose",
38 | "keywords": [
39 | "list containers",
40 | "show containers"
41 | ],
42 | "shell": [
43 | "docker compose ps --all",
44 | "docker compose ps -a"
45 | ]
46 | },
47 | {
48 | "desc": "Stop containers",
49 | "cat": "Compose",
50 | "keywords": [
51 | "stop containers"
52 | ],
53 | "shell": [
54 | "docker compose stop"
55 | ]
56 | },
57 | {
58 | "desc": "Stop and remove containers, networks created by up",
59 | "cat": "Compose",
60 | "keywords": [
61 | "stop containers",
62 | "remove containers",
63 | "delete containers"
64 | ],
65 | "shell": [
66 | "docker compose down"
67 | ]
68 | },
69 | {
70 | "desc": "Pull images defined in a Compose file",
71 | "cat": "Compose",
72 | "keywords": [],
73 | "shell": [
74 | "docker compose pull"
75 | ]
76 | },
77 | {
78 | "desc": "Create a container using Docker Compose",
79 | "cat": "Compose",
80 | "keywords": [],
81 | "shell": [
82 | "docker compose create"
83 | ]
84 | },
85 | {
86 | "desc": "Build and start containers using Docker Compose",
87 | "cat": "Compose",
88 | "keywords": [],
89 | "shell": [
90 | "docker compose up --build",
91 | "docker compose up -d --build"
92 | ]
93 | },
94 | {
95 | "desc": "Scale services defined in a Compose file",
96 | "cat": "Compose",
97 | "keywords": [],
98 | "shell": [
99 | "docker compose up -d --scale service_name=num"
100 | ]
101 | },
102 | {
103 | "desc": "View the logs of services defined in a Compose file",
104 | "cat": "Compose",
105 | "keywords": [],
106 | "shell": [
107 | "docker compose logs",
108 | "docker compose logs service_name"
109 | ]
110 | },
111 | {
112 | "desc": "Execute a command in a running container defined in a Compose file",
113 | "cat": "Compose",
114 | "keywords": [],
115 | "shell": [
116 | "docker compose exec service_name command"
117 | ]
118 | },
119 | {
120 | "desc": "Run a one-off command in a service container defined in a Compose file",
121 | "cat": "Compose",
122 | "keywords": [],
123 | "shell": [
124 | "docker compose run service_name command"
125 | ]
126 | },
127 | {
128 | "desc": "Remove stopped containers created by up",
129 | "cat": "Compose",
130 | "keywords": [],
131 | "shell": [
132 | "docker compose rm"
133 | ]
134 | },
135 | {
136 | "desc": "Build or rebuild services",
137 | "cat": "Compose",
138 | "keywords": [],
139 | "shell": [
140 | "docker compose build",
141 | "docker compose build service_name"
142 | ]
143 | },
144 | {
145 | "desc": "List running containers",
146 | "cat": "Container",
147 | "keywords": [
148 | "list containers",
149 | "show containers"
150 | ],
151 | "shell": [
152 | "docker ps",
153 | "docker container list",
154 | "docker container ls"
155 | ]
156 | },
157 | {
158 | "desc": "List all containers",
159 | "cat": "Container",
160 | "keywords": [],
161 | "shell": [
162 | "docker ps --all",
163 | "docker ps -a",
164 | "docker container list --all",
165 | "docker container ls --all"
166 | ]
167 | },
168 | {
169 | "desc": "Run a container from my-image:1.0",
170 | "cat": "Container",
171 | "keywords": [],
172 | "shell": [
173 | "docker run my-image:1.0",
174 | "docker container run my-image:1.0"
175 | ]
176 | },
177 | {
178 | "desc": "Run a container from my-image:1.0 with the name www",
179 | "cat": "Container",
180 | "keywords": [],
181 | "shell": [
182 | "docker run --name www my-image:1.0"
183 | ]
184 | },
185 | {
186 | "desc": "Run a container from my-image:1.0 exposing internal port 3000 to external port 80",
187 | "cat": "Container",
188 | "keywords": [],
189 | "shell": [
190 | "docker run --name www -p 80:3000 my-image:1.0"
191 | ]
192 | },
193 | {
194 | "desc": "Stop a container by the name www",
195 | "cat": "Container",
196 | "keywords": [],
197 | "shell": [
198 | "docker stop www",
199 | "docker container stop www"
200 | ]
201 | },
202 | {
203 | "desc": "Stop containers by the name www1 www2 ...",
204 | "cat": "Container",
205 | "keywords": [],
206 | "shell": [
207 | "docker stop www1 www2",
208 | "docker container stop www1 www2"
209 | ]
210 | },
211 | {
212 | "desc": "Stop all the containers that match a keyword example",
213 | "cat": "Container",
214 | "keywords": [],
215 | "shell": [
216 | "docker stop $(docker ps -a | grep \"example\" | awk '{print $1}')"
217 | ]
218 | },
219 | {
220 | "desc": "Kill a container by the name www",
221 | "cat": "Container",
222 | "keywords": [],
223 | "shell": [
224 | "docker kill www",
225 | "docker container kill www"
226 | ]
227 | },
228 | {
229 | "desc": "Kill containers by the name www1 www2 ...",
230 | "cat": "Container",
231 | "keywords": [],
232 | "shell": [
233 | "docker kill www1 www2",
234 | "docker container kill www1 www2"
235 | ]
236 | },
237 | {
238 | "desc": "Remove containers by the name www1 www2 ...",
239 | "cat": "Container",
240 | "keywords": [],
241 | "shell": [
242 | "docker rm www1 www2",
243 | "docker container rm www1 www2"
244 | ]
245 | },
246 | {
247 | "desc": "Remove all the containers that match a keyword example",
248 | "cat": "Container",
249 | "keywords": [],
250 | "shell": [
251 | "docker rm $(docker ps -a | grep \"example\" | awk '{print $1}')"
252 | ]
253 | },
254 | {
255 | "desc": "Runs id in www container",
256 | "cat": "Container",
257 | "keywords": [],
258 | "shell": [
259 | "docker exec www id",
260 | "docker container exec www id"
261 | ]
262 | },
263 | {
264 | "desc": "Run an interactive bash shell on the container",
265 | "cat": "Container",
266 | "keywords": [],
267 | "shell": [
268 | "docker exec -it ubuntu bash",
269 | "docker container exec -it ubuntu bash"
270 | ]
271 | },
272 | {
273 | "desc": "Run a container in the background from my-image:1.0",
274 | "cat": "Container",
275 | "keywords": [],
276 | "shell": [
277 | "docker run -d my-image:1.0",
278 | "docker container run -d my-image:1.0"
279 | ]
280 | },
281 | {
282 | "desc": "Attach to a running container named www",
283 | "cat": "Container",
284 | "keywords": [],
285 | "shell": [
286 | "docker attach www",
287 | "docker container attach www"
288 | ]
289 | },
290 | {
291 | "desc": "Inspect a container named www",
292 | "cat": "Container",
293 | "keywords": [],
294 | "shell": [
295 | "docker inspect www",
296 | "docker container inspect www"
297 | ]
298 | },
299 | {
300 | "desc": "List logs of a container named www",
301 | "cat": "Container",
302 | "keywords": [],
303 | "shell": [
304 | "docker logs www",
305 | "docker container logs www"
306 | ]
307 | },
308 | {
309 | "desc": "Start a stopped container named www",
310 | "cat": "Container",
311 | "keywords": [],
312 | "shell": [
313 | "docker start www",
314 | "docker container start www"
315 | ]
316 | },
317 | {
318 | "desc": "Restart a running container named www",
319 | "cat": "Container",
320 | "keywords": [],
321 | "shell": [
322 | "docker restart www",
323 | "docker container restart www"
324 | ]
325 | },
326 | {
327 | "desc": "Pause a running container named www",
328 | "cat": "Container",
329 | "keywords": [],
330 | "shell": [
331 | "docker pause www",
332 | "docker container pause www"
333 | ]
334 | },
335 | {
336 | "desc": "Unpause a paused container named www",
337 | "cat": "Container",
338 | "keywords": [],
339 | "shell": [
340 | "docker unpause www",
341 | "docker container unpause www"
342 | ]
343 | },
344 | {
345 | "desc": "Rename a container named www to web",
346 | "cat": "Container",
347 | "keywords": [],
348 | "shell": [
349 | "docker rename www web",
350 | "docker container rename www web"
351 | ]
352 | },
353 | {
354 | "desc": "Build a image with the name my-image and tag 1.0",
355 | "cat": "Image",
356 | "keywords": [
357 | "create image"
358 | ],
359 | "shell": [
360 | "docker build -t my-image:1.0 ."
361 | ]
362 | },
363 | {
364 | "desc": "List local images",
365 | "cat": "Image",
366 | "keywords": [
367 | "list images",
368 | "show images"
369 | ],
370 | "shell": [
371 | "docker image ls"
372 | ]
373 | },
374 | {
375 | "desc": "Delete local image by the name:tag my-image:1.0",
376 | "cat": "Image",
377 | "keywords": [
378 | "delete image",
379 | "remove image"
380 | ],
381 | "shell": [
382 | "docker image rm my-image:1.0"
383 | ]
384 | },
385 | {
386 | "desc": "Build an image in the current directory with the name my-image",
387 | "cat": "Image",
388 | "keywords": [
389 | "create image"
390 | ],
391 | "shell": [
392 | "docker build -t my-image ."
393 | ]
394 | },
395 | {
396 | "desc": "Pull image example from a registry",
397 | "cat": "Image",
398 | "keywords": [],
399 | "shell": [
400 | "docker pull example",
401 | "docker image pull example"
402 | ]
403 | },
404 | {
405 | "desc": "Push image my-image to repository myrepo under a registry",
406 | "cat": "Image",
407 | "keywords": [],
408 | "shell": [
409 | "docker push myrepo/my-image:2.0",
410 | "docker image push myrepo/my-image:2.0"
411 | ]
412 | },
413 | {
414 | "desc": "List networks",
415 | "cat": "Network",
416 | "keywords": [
417 | "list networks",
418 | "show networks"
419 | ],
420 | "shell": [
421 | "docker network ls"
422 | ]
423 | },
424 | {
425 | "desc": "Create a network with the name my-network",
426 | "cat": "Network",
427 | "keywords": [],
428 | "shell": [
429 | "docker network create my-network"
430 | ]
431 | },
432 | {
433 | "desc": "Remove a network with the name my-network",
434 | "cat": "Network",
435 | "keywords": [],
436 | "shell": [
437 | "docker network rm my-network"
438 | ]
439 | },
440 | {
441 | "desc": "Inspect a network with the name my-network",
442 | "cat": "Network",
443 | "keywords": [],
444 | "shell": [
445 | "docker network inspect my-network"
446 | ]
447 | },
448 | {
449 | "desc": "Remove all unused containers, networks, images (both dangling and unreferenced)",
450 | "cat": "System",
451 | "keywords": [
452 | "clean containers",
453 | "remove containers",
454 | "storage spaces",
455 | "cleanup",
456 | "delete"
457 | ],
458 | "shell": [
459 | "docker system prune"
460 | ]
461 | },
462 | {
463 | "desc": "Remove all unused containers, networks, images (both dangling and unreferenced), and volumes.",
464 | "cat": "System",
465 | "keywords": [
466 | "clean containers",
467 | "remove containers",
468 | "storage spaces",
469 | "cleanup",
470 | "delete"
471 | ],
472 | "shell": [
473 | "docker system prune --volumes"
474 | ]
475 | },
476 | {
477 | "desc": "Remove all unused containers, networks, all unused images, and volumes.",
478 | "cat": "System",
479 | "keywords": [
480 | "clean containers",
481 | "remove containers",
482 | "storage spaces",
483 | "cleanup",
484 | "delete"
485 | ],
486 | "shell": [
487 | "docker system prune --all --volumes"
488 | ]
489 | },
490 | {
491 | "desc": "List volumes",
492 | "cat": "Volume",
493 | "keywords": [
494 | "list volumes",
495 | "show volumes"
496 | ],
497 | "shell": [
498 | "docker volume ls"
499 | ]
500 | },
501 | {
502 | "desc": "Create a volume",
503 | "cat": "Volume",
504 | "keywords": [
505 | "volume creation"
506 | ],
507 | "shell": [
508 | "docker volume create hello"
509 | ]
510 | },
511 | {
512 | "desc": "Remove all unused local volumes",
513 | "cat": "Volume",
514 | "keywords": [
515 | "Remove volumes"
516 | ],
517 | "shell": [
518 | "docker volume prune"
519 | ]
520 | },
521 | {
522 | "desc": "Backup my_volume to my_backup.tar",
523 | "cat": "Volume",
524 | "keywords": [
525 | "volume backup",
526 | "data backup"
527 | ],
528 | "shell": [
529 | "docker run --rm --volume my_volume:/mount_bkp --volume $(pwd):/backup ubuntu tar cvf /backup/my_backup.tar /mount_bkp"
530 | ]
531 | },
532 | {
533 | "desc": "Restore my_backup.tar to my_volume",
534 | "cat": "Volume",
535 | "keywords": [
536 | "volume restore",
537 | "data restore"
538 | ],
539 | "shell": [
540 | "docker run --rm --volume my_volume:/mount_bkp --volume $(pwd):/backup ubuntu tar xvf /backup/my_backup.tar -C /mount_bkp --strip 1"
541 | ]
542 | }
543 | ]
--------------------------------------------------------------------------------