Here are some of the most useful Key Docker commands:

1. Docker Basics

docker version: Displays the installed Docker version details.

docker version

docker info: Provides detailed information about the Docker installation.
docker info

2. Working with Images

docker build: Builds an image from a Dockerfile.
docker build -t my-image 

docker pull: Downloads an image from a Docker registry (e.g., Docker Hub).
docker pull nginx

docker images: Lists all images on the local machine.
docker images

docker rmi: Removes one or more images from the local machine.
docker rmi image_id

docker tag : The docker tag command useful for renaming images or preparing them for pushing to a registry.

docker commit: The docker commit command creates a new image from a container's changes.

docker push: The docker push command uploads a tagged image to a Docker registry. 
docker push [OPTIONS] NAME[:TAG]

3. Working with Containers

docker run: Creates and starts a container from an image.
docker run -d -p 80:80 nginx

docker ps: Lists all running containers.
docker ps

docker ps -a: Lists all containers, including stopped ones.
docker ps -a

docker stop: Stops a running container.
docker stop container_id

docker start: Starts a stopped container.
docker start container_id

docker restart: Restarts a running container.
docker restart container_id

docker rm: Removes one or more containers.
docker rm container_id

4. Inspect and Manage

docker logs: Fetches the logs of a container.
docker logs container_id

docker exec: Runs a command in a running container.
docker exec -it container_id bash

docker inspect: Returns detailed information about a container or image.
docker inspect container_id

5. Networks and Volumes
docker network ls: Lists all Docker networks.
docker network ls

docker network create: Creates a new network.
docker network create my-network

docker volume ls: Lists all Docker volumes.
docker volume ls

docker volume create: Creates a new volume.
docker volume create my-volume

6. Cleanup

docker system prune: Cleans up unused Docker objects (images, containers, volumes, and networks).
docker system prune

7. Docker Compose

docker-compose up: Builds, (re)creates, starts, and attaches to containers for a service defined in a docker-compose.yml file.
docker-compose up

docker-compose down: Stops and removes containers, networks, images, and volumes defined in a docker-compose.yml file.
docker-compose down