# Docker and Docker-Compose Cheat-Sheet

## 📌 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 &lt;image name&gt; - Create a container
    
* docker create -it &lt;image name&gt; - Create container in interactive mode
    
* docker rm &lt;container name&gt; - Delete container
    
* docker logs &lt;container name&gt; - View logs of running container
    
* docker port - Show port mapping for a container
    
* docker stats - Show usage statistics for a container
    
* docker run &lt;image&gt; - To run a container
    
* docker run -p &lt;host:container&gt; &lt;image&gt; - map host port to container port
    
* docker run -d - Run a detached container
    
* docker run -it - Run an interactive process
    
* docker start &lt;container name&gt; - start a container
    
* docker stop &lt;container name&gt; - stop a container
    
* docker kill &lt;container name&gt; - To kill the container
    
* docker exec -it &lt;container&gt; &lt;shell&gt; - Run a shell inside container
    

### Docker Images

* docker build &lt;dockerfilepath&gt; - create image from docker file
    
* docker build . - Build an image from the current path
    
* docker build -t &lt;name&gt;:&lt;tag&gt; - Create image and tag it
    
* docker pull &lt;image&gt; - Pull an image
    
* docker push &lt;image&gt; - 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 &lt;network&gt;- Remove a network
    
* docker network inspect &lt;network &gt; - 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 &lt;volume&gt;- Create a new volume
    
* docker volume inspect &lt;volume &gt; - To check information of volume
    
* docker volume rm &lt;volume&gt; - 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
