An open API service indexing awesome lists of open source software.

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! ๐Ÿš€

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! ๐Ÿณโœจ

---