#Day20 - Docker Cheat Sheet
๐ Elevate Your Docker Expertise: Introducing My Docker & Docker-Compose Cheat Sheet! ๐
๐ณ Docker Cheat Sheet ๐
โ Docker Basics:
- Build an image: docker build -t image_name .
- List images: docker images
- Remove an image: docker rmi image_name
- Pull an image: docker pull image_name
โ Containers:
- Run a container: docker run -d --name my_container image_name
- List running containers: docker ps
- List all containers: docker ps -a
- Stop a container: docker stop container_id
- Start a stopped container: docker start container_id
- Remove a container: docker rm container_id
- Attach to a running container: docker attach container_id
- Execute a command in a container: docker exec -it container_id command
โ Docker Compose:
- Start services defined in a Compose file: docker-compose up -d
- Stop services defined in a Compose file: docker-compose down
- View logs for a service: docker-compose logs service_name
- Scale services: docker-compose up -d --scale service_name=3
โ Networks:
- List networks: docker network ls
- Create a network: docker network create my_network
- Attach a container to a network: docker network connect my_network container_name
- Detach a container from a network: docker network disconnect my_network container_name
โ Volumes:
- List volumes: docker volume ls
- Create a volume: docker volume create my_volume
- Remove a volume: docker volume rm my_volume
- Mount a volume in a container: docker run -v my_volume:/path/in/container image_name
โ Images:
- Search for an image: docker search image_name
- Tag an image: docker tag image_id new_image_name
- Push an image to a registry: docker push new_image_name
โ Clean Up:
- Remove all stopped containers: docker container prune
- Remove all unused images: docker image prune
- Remove all unused networks: docker network prune
- Remove all unused volumes: docker volume prune
Happy Dockerizing! ๐ณ
Spread the knowledge by sharing this cheat sheet on LinkedIn and other platforms. Your expertise is a beacon of inspiration for others on their DevOps journeys. Happy Learning! ๐
Subscribe to my newsletter
Read articles from Shefali Mishra directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by