Docker and Docker-Compose Cheat-Sheet
Day-20 #90daysofdevops

Nikhil Patil
π¨βπ» I love Linux & DevOps! π»
π§ Linuxπ¨βπ» | DevOps & Cloud Enthusiast | π Azure Admin | π οΈ Ansible | π Git | π³ Docker | π OpenLDAP | π₯οΈ System Admin | | π Jenkins π οΈ
π Pune
π I'm really into using and managing computers with Linux. I also like making things work smoothly and quickly.
π I work with Microsoft Azure, use tools like Ansible and Git to automate tasks, and make software run in containers with Docker.
π I handle access and security using OpenLDAP, and I'm all about keeping systems running smoothly.
π Exploring opportunities in cloud and DevOps.
π§ Get in touch: nikrpatil1997@gmail.com
π Introduction
We have completedβ the Docker hands-on and we learned something interesting from it.π
Now it's time to take your Docker skills to the next level by creating a comprehensive cheat-sheet of all the commands we have learned so far. This cheat-sheet should include commands for both Docker and Docker-Compose, as well as brief explanations of their usage.
π Docker and Docker-Compose Cheat-Sheet
Docker Container
docker ps - List the running containers
docker ps -a - List all the containers running and stopped
docker create <image name> - Create a container
docker create -it <image name> - Create container in interactive mode
docker rm <container name> - Delete container
docker logs <container name> - View logs of running container
docker port - Show port mapping for a container
docker stats - Show usage statistics for a container
docker run <image> - To run a container
docker run -p <host:container> <image> - map host port to container port
docker run -d - Run a detached container
docker run -it - Run an interactive process
docker start <container name> - start a container
docker stop <container name> - stop a container
docker kill <container name> - To kill the container
docker exec -it <container> <shell> - Run a shell inside container
Docker Images
docker build <dockerfilepath> - create image from docker file
docker build . - Build an image from the current path
docker build -t <name>:<tag> - Create image and tag it
docker pull <image> - Pull an image
docker push <image> - Push an image
docker images - To see docker images locally
docker rmi - Remove docker images
docker image prune - Remove all images
Docker Networking
docker network ls - View available network
docker network rm <network>- Remove a network
docker network inspect <network > - Show information about a network
General Commands
docker login - Login to the docker registry
docker logout - Log out of a docker registry
Docker volume
docker volume ls - List of volume
docker volume create <volume>- Create a new volume
docker volume inspect <volume > - To check information of volume
docker volume rm <volume> - Remove a volume
Docker Compose
docker-compose up - Start container defined in the docker-compose file
docker-compose up -d - Run containers in detached mode
docker-compose down - stop containers and remove
docker-compose build - Build docker image defined in the docker-compose file
docker-compose stop - Stop containers created by the docker-compose file
docker-compose logs - View all logs




