Rakesh Jain
Rakesh Jain

@devops_tech

23 Tweets 99 reads Sep 07, 2023
Mastering Docker Commands!
20 Docker commands with explanations - A Thread 👇
1/20 🐳 Check Docker version:
docker --version
📜 Explanation: Check Docker version installed on your system.
2/20 🐳 Download Docker image:
docker pull <image_name>
📜 Explanation: Download a Docker image from a container registry.
3/20 🐳 List local Docker images:
docker image ls
📜 Explanation: List all Docker images on your local machine.
4/20 🐳 List running containers:
docker container ls
📜 Explanation: Display running containers with their details.
5/20 🐳 Start interactive container shell:
docker container run -it <image_name> bash
📜 Explanation: Start a new container and open an interactive shell.
6/20 🐳 Stop a container:
docker container stop <container_id>
📜 Explanation: Stop a running container by specifying its ID.
7/20 🐳 Remove a container:
docker image rm <image_name>
📜 Explanation: Remove a stopped container by specifying its ID.
8/20 🐳 Delete a Docker image:
docker rmi <image_name>
📜 Explanation: Delete a Docker image from your local repository.
9/20 🐳 Build Docker image from Dockerfile:
docker image build -t <image_name> <path_to_dockerfile>
📜 Explanation: Build a new Docker image from a Dockerfile.
10/20 🐳 Start containers with Docker Compose:
docker-compose up
📜 Explanation: Start containers defined in a Docker Compose file.
11/20 🐳 View container logs:
docker container logs <container_id>
📜 Explanation: View the logs of a specific container.
12/20 🐳 Execute command inside container:
docker container exec -it <container_id> <command>
📜 Explanation: Execute a command inside a running container.
13/20 🐳 Create custom Docker network:
docker network create <network_name>
📜 Explanation: Create a custom Docker network.
14/20 🐳 Create named volume for data storage:
docker volume create <volume_name>
📜 Explanation: Create a named volume for persistent data storage.
15/20 🐳 Stop and remove containers with Docker Compose:
docker-compose down
📜 Explanation: Stop and remove containers defined in a Docker Compose file.
16/20 🐳 Display container resource stats:
docker container stats
📜 Explanation: Display resource usage statistics of all running containers.
17/20 🐳 Save Docker image to tarball file:
docker image save -o <output_file.tar> <image_name>
📜 Explanation: Save a Docker image to a tarball file.
18/20 🐳 Load Docker image from tarball file:
docker image load -i <input_file.tar>
📜 Explanation: Load a Docker image from a tarball file.
19/20 🐳 Initialize Docker Swarm mode cluster:
docker swarm init
📜 Explanation: Initialize a Docker Swarm mode cluster.
20/20 🐳 List services in Docker Swarm cluster:
docker service ls
📜 Explanation: List services running in a Docker Swarm cluster.
Remember to replace <image_name>, <container_id>, <path_to_dockerfile>, and other placeholders with actual values when using these commands.
Happy Dockerizing! 🚀 #Docker #DevOps
Repost the thread if you find it useful. Thanks!

Loading suggestions...