Docker commands used for managing containers and images:

				
					docker --version - Displays the installed Docker version
docker info - Shows system-wide information about Docker
docker run <image> - Runs a command in a new container using the specified image
docker run -it <image> - Runs a command in an interactive container with a TTY
docker start <container> - Starts a stopped container
docker stop <container> - Stops a running container
docker restart <container> - Restarts a container
docker ps - Lists all running containers
docker ps -a - Lists all containers, including stopped ones
docker rm <container> - Removes a container
docker rm $(docker ps -a -q) - Removes all containers
docker rmi <image> - Removes an image
docker rmi $(docker images -q) - Removes all images
docker logs <container> - Fetches the logs of a container
docker exec -it <container> <command> - Executes a command in a running container
docker attach <container> - Attaches to a running container
docker cp <container>:<path> <local-path> - Copies files or directories from a container to the host
docker cp <local-path> <container>:<path> - Copies files or directories from the host to a container
docker images - Lists all images available locally
docker pull <image> - Pulls an image from the Docker registry
docker push <repository>:<tag> - Pushes an image to a Docker registry
docker search <keyword> - Searches the Docker registry for images matching the keyword
docker build -t <tag> <path> - Builds a Docker image from a Dockerfile at the specified path
docker commit <container> <repository>:<tag> - Creates a new image from a container's changes
docker tag <source-image>:<tag> <target-image>:<tag> - Tags an image with a new alias
docker login - Logs in to the Docker registry
docker logout - Logs out of the Docker registry
docker network ls - Lists all networks available
docker network create <network> - Creates a new network
docker network rm <network> - Removes a network
docker network inspect <network> - Displays information about a network
docker network connect <network> <container> - Connects a container to a network
docker network disconnect <network> <container> - Disconnects a container from a network
docker volume ls - Lists all volumes available
docker volume create <volume> - Creates a new volume
docker volume rm <volume> - Removes a volume
docker volume inspect <volume> - Displays information about a volume
docker system df - Shows disk usage for Docker objects
docker system prune - Removes unused data (containers, images, volumes, networks)
docker system prune -a - Removes all unused data, including dangling images
docker top <container> - Displays the running processes in a container
docker pause <container> - Pauses all processes within a container
docker unpause <container> - Unpauses all processes within a container
docker stats - Shows real-time resource usage for running containers
docker stats <container> - Shows real-time resource usage for a specific container
docker inspect <object> - Returns detailed information about a container, image, volume, or network
docker diff <container> - Shows the differences in the filesystem of a container compared to its base image
docker update <options> <container> - Updates the configuration of one or more containers
docker rename <old-name> <new-name> - Renames a container
docker port <container> - Lists the port mappings for a container
docker save <image> -o <file> - Saves an image to a tar archive
docker load -i <file> - Loads an image from a tar archive
docker import <file> - Imports the contents of a tarball to create a filesystem image
docker export <container> -o <file> - Exports a container's filesystem as a tar archive
docker kill <container> - Sends a signal to a container, usually to forcefully stop it
docker wait <container> - Blocks until a container stops, then prints its exit code
docker events - Shows real-time events from the Docker daemon
docker node ls - Lists all nodes in a Docker swarm
docker node inspect <node> - Displays information about a swarm node
docker node rm <node> - Removes a node from the swarm
docker service create <options> <image> - Creates a new service based on the specified image
docker service ls - Lists all services in the swarm
docker service inspect <service> - Displays information about a swarm service
docker service update <options> <service> - Updates the configuration of a service
docker service rm <service> - Removes a swarm service
docker swarm init - Initializes a new Docker swarm
docker swarm join <options> - Joins a node to an existing swarm
docker swarm leave - Leaves a swarm
				
			
Social Share: