Useful Docker Commands In daily use

Search for a command to run...

No comments yet. Be the first to comment.
A context manager is an object that defines a runtime context and provides methods to establish and clean up the context. It is used with the with statement in Python to manage resources effectively and ensure that necessary cleanup (like closing a f...

Optimizing a Django application is crucial for ensuring that it runs efficiently, especially under heavy load or with large datasets. There are various aspects of a Django application you can optimize, including database interactions, middleware, sta...

This guide will walk you through the detailed process of setting up and using Celery with Redis in a Django application. We'll cover task creation, enqueuing tasks, using Redis as a message broker, processing tasks with Celery workers, and scheduling...

Redis is an open-source, in-memory data structure store that can be used as a database, cache, and message broker. It supports various data structures like strings, hashes, lists, sets, and sorted sets, making it versatile for a wide range of use cas...

docker version
Shows the Docker version installed on your system.
docker version
docker info
Displays system-wide information about Docker, including number of containers, images, and other details.
docker info
docker help
Provides help on using Docker commands.
docker help
docker pull
Downloads an image from a Docker registry (e.g., Docker Hub).
docker pull <image_name>
docker images
Lists all the images on your local machine.
docker images
docker rmi
Removes one or more images from your local machine.
docker rmi <image_id>
docker tag
Tags an image with a new name.
docker tag <existing_image> <new_image:tag>
docker build
Builds an image from a Dockerfile.
docker build -t <image_name:tag> <path_to_dockerfile>
docker push
Uploads an image to a Docker registry.
docker push <image_name:tag>
docker run
Runs a container from an image.
docker run -d --name <container_name> <image_name>
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 container.
docker restart <container_id>
docker rm
Removes a container.
docker rm <container_id>
docker logs
Displays the logs of a container.
docker logs <container_id>
docker exec
Runs a command in a running container.
docker exec -it <container_id> <command>
docker attach
Attaches your terminal to a running container.
docker attach <container_id>
docker network ls
Lists all Docker networks.
docker network ls
docker network create
Creates a new Docker network.
docker network create <network_name>
docker network inspect
Displays detailed information about a network.
docker network inspect <network_name>
docker network connect
Connects a container to a network.
docker network connect <network_name> <container_id>
docker network disconnect
Disconnects a container from a network.
docker network disconnect <network_name> <container_id>
docker volume ls
Lists all Docker volumes.
docker volume ls
docker volume create
Creates a new Docker volume.
docker volume create <volume_name>
docker volume inspect
Displays detailed information about a volume.
docker volume inspect <volume_name>
docker volume rm
Removes a Docker volume.
docker volume rm <volume_name>
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, volumes, and images created by docker-compose up.
docker-compose down
docker-compose ps
Lists containers started by Docker Compose.
docker-compose ps
docker-compose logs
Displays log output from services managed by Docker Compose.
docker-compose logs
docker-compose exec
Executes a command in a running service container.
docker-compose exec <service_name> <command>
docker system prune
Removes all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes.
docker system prune
docker container prune
Removes all stopped containers.
docker container prune
docker image prune
Removes unused images.
docker image prune
docker volume prune
Removes all unused volumes.
docker volume prune
docker inspect
Returns low-level information about Docker objects.
docker inspect <container_id or image_id>
docker diff
Inspects changes to files or directories on a container’s filesystem.
docker diff <container_id>
docker scan
Scans your Docker images for vulnerabilities.
docker scan <image_name>
By mastering these commands, you can effectively manage Docker images, containers, networks, volumes, and more, enhancing your ability to deploy and maintain containerized applications.