https://github.com/shihabshahrier/docker-command-cheat-sheet
Docker simplifies container management for developers. Below is a fun and easy guide to the most useful Docker commands you'll need. Let's start building and managing containers like a pro! ๐
https://github.com/shihabshahrier/docker-command-cheat-sheet
docker docker-compose docker-image docker-network
Last synced: 7 months ago
JSON representation
Docker simplifies container management for developers. Below is a fun and easy guide to the most useful Docker commands you'll need. Let's start building and managing containers like a pro! ๐
- Host: GitHub
- URL: https://github.com/shihabshahrier/docker-command-cheat-sheet
- Owner: shihabshahrier
- Created: 2025-01-04T17:02:10.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-04T17:04:58.000Z (about 1 year ago)
- Last Synced: 2025-01-15T19:38:44.613Z (about 1 year ago)
- Topics: docker, docker-compose, docker-image, docker-network
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ณ Docker Command Cheat Sheet
Docker simplifies container management for developers. Below is a **fun and easy guide** to the most useful Docker commands you'll need. Let's start building and managing containers like a pro! ๐
---
## ๐ ๏ธ **Docker Basics**
1. **Run an Ubuntu Container Interactively**
```bash
docker run -it ubuntu
```
*๐ง Launches an Ubuntu container in interactive mode.*
2. **List All Docker Images**
```bash
docker images
```
*๐ฆ Displays all images available locally.*
3. **Access a Running Container's Shell**
```bash
docker exec -it bash
```
*๐ Opens a Bash shell inside a running container.*
4. **Run a Command Inside a Running Container**
```bash
docker exec ls
```
*๐ Executes the `ls` command inside the specified container.*
---
## ๐ **Port Exposure**
5. **Run a Container and Expose Ports**
```bash
docker run -it -p 1025:1025
```
*๐ก Maps port 1025 on the host to port 1025 in the container.*
---
## ๐งฑ **Building and Managing Images**
6. **Build an Image from a Dockerfile**
```bash
docker build -t simplemessenger
```
*๐จ Builds an image tagged as `simplemessenger` from the specified path.*
7. **Remove an Image**
```bash
docker rmi
```
*๐ฎ Deletes an unwanted image from your local repository.*
---
## ๐ **Docker Compose**
8. **Start Services Defined in `docker-compose.yml`**
```bash
docker compose up -d
```
*๐ Launches services in detached mode.*
9. **Stop and Remove Docker Compose Services**
```bash
docker compose down
```
*๐ Stops services and cleans up containers, networks, and volumes.*
---
## ๐ **Docker Networks**
10. **Run a Container on the Host Network**
```bash
docker run -it --network=host
```
*๐ Shares the host's network stack.*
11. **Run a Container on the Default Bridge Network**
```bash
docker run -it --network=bridge
```
*๐ Uses Dockerโs default bridge network.*
12. **Run a Container Without a Network**
```bash
docker run -it --network=none
```
*๐ซ Launches the container with no network connection.*
13. **Create a Custom Bridge Network**
```bash
docker network create -d bridge
```
*๐ Sets up a new isolated bridge network.*
---
## ๐ **Additional Useful Commands**
14. **List Running Containers**
```bash
docker ps
```
*๐ข Displays currently running containers.*
15. **List All Containers (Including Stopped)**
```bash
docker ps -a
```
*๐ Lists all containers, active or stopped.*
16. **Stop a Container**
```bash
docker stop
```
*๐ Stops a running container.*
17. **Remove a Container**
```bash
docker rm
```
*๐ฎ Deletes a stopped container.*
18. **Check Logs of a Container**
```bash
docker logs
```
*๐ Displays logs for troubleshooting or monitoring.*
19. **Copy Files To/From a Container**
```bash
docker cp :
docker cp :
```
*๐ค๐ฅ Transfers files between your host and container.*
20. **Prune Unused Docker Resources**
```bash
docker system prune
```
*๐งน Cleans up unused containers, networks, and images.*
21. **Inspect a Container or Image**
```bash
docker inspect
```
*๐ Provides detailed information about containers or images.*
22. **Start a Stopped Container**
```bash
docker start
```
*๐ Revives a previously stopped container.*
23. **Attach to a Running Container**
```bash
docker attach
```
*๐ Connects to a running containerโs input/output streams.*
24. **Tag an Image for a Repository**
```bash
docker tag :
```
*๐ท๏ธ Prepares an image for pushing to a repository.*
25. **Push an Image to Docker Hub**
```bash
docker push :
```
*๐ Uploads a tagged image to Docker Hub.*
---
## ๐งน **Pro Tip: Cleaning Up**
Keep your system tidy with this command:
```bash
docker system prune
```
*โจ Cleans up all unused containers, images, and networks.*
---
## ๐ **Thatโs It!**
This cheat sheet is your go-to guide for all the essential Docker commands. Save it, share it, and keep experimenting. With Docker, the possibilities are endless! ๐ณโจ
---