Table Of Contents
- 1. List Docker images:
- 2. List running containers:
- 3. List all containers (including stopped):
- 4. Pull an image from Docker Hub:
- 5. Run a container from an image:
- 6. Run a container in detached mode (background):
- 7. Run a container with a custom name:
- 8. Stop a running container:
- 9. Start a stopped container:
- 10. Remove a container:
- 11. Remove an image:
- 12. Execute a command in a running container:
- 13. Show logs of a container:
- 14. Build an image from Dockerfile:
- 15. Inspect a container (details):
- 16. Inspect an image (details):
- 17. List networks:
- 18. Create a new network:
- 19. Attach a network to a container:
- 20. Remove a network:
- 21. Pause a running container:
- 22. Unpause a paused container:
- 23. Restart a container:
- 24. Display Docker disk usage:
- 25. Remove all stopped containers:
- 26. Remove all unused images:
- 27. Remove all unused networks:
- 28. Remove all unused volumes:
- 29. Display Docker version information:
- 30. Display Docker system-wide information:
- 31. Disconnect a container from a network:
- 32. Display Docker usage information including storage and memory:
- 33. Display Docker storage usage by volume:
- 34. Display detailed information about Docker events in real-time:
- 35. Display detailed information about Docker swarm nodes:
- 36. Display detailed information about Docker services:
- 37. Create a new Docker service:
- 38. Scale a Docker service to a specific number of replicas:
- 39. Update a Docker service with a new image or configuration:
- 40. Remove a Docker service:
- 41. Display information about a specific Docker swarm:
- 42. Join a Docker swarm as a worker or manager:
- 43. Leave a Docker swarm:
- 44. Promote a node to be a manager in Docker swarm:
- 45. Demote a manager node to be a worker in Docker swarm:
- 46. Drain a node in Docker swarm to prevent new tasks from being scheduled:
- 47. Update the configuration of a Docker swarm:
- 48. Display detailed information about Docker configs:
- 49. Create a Docker config:
- 50. Remove a Docker config:
- 51. Display detailed information about Docker secrets:
- 52. Create a Docker secret:
- 53. Remove a Docker secret:
- 54. Display detailed information about Docker plugins:
- 55. Install a Docker plugin:
- 56. Upgrade a Docker plugin:
- 57. Remove a Docker plugin:
- 58. Enable experimental features in Docker:
- 59. Display information about Docker network plugins:
- 60. Configure Docker to use a specific network plugin:
- Conclusion
1. List Docker images:
docker images
2. List running containers:
docker ps
3. List all containers (including stopped):
docker ps -a
4. Pull an image from Docker Hub:
docker pull <image_name>
5. Run a container from an image:
docker run <image_name>
6. Run a container in detached mode (background):
docker run -d <image_name>
7. Run a container with a custom name:
docker run --name <container_name> <image_name>
8. Stop a running container:
docker stop <container_id/name>
9. Start a stopped container:
docker start <container_id/name>
10. Remove a container:
docker rm <container_id/name>
11. Remove an image:
docker rmi <image_id/name>
12. Execute a command in a running container:
docker exec <container_id/name> <command>
13. Show logs of a container:
docker logs <container_id/name>
14. Build an image from Dockerfile:
docker build -t <image_name> <path_to_Dockerfile>
15. Inspect a container (details):
docker inspect <container_id/name>
16. Inspect an image (details):
docker inspect <image_id/name>
17. List networks:
docker network ls
18. Create a new network:
docker network create <network_name>
19. Attach a network to a container:
docker network connect <network_name> <container_id/name>
20. Remove a network:
docker network rm <network_name>
21. Pause a running container:
docker pause <container_id/name>
22. Unpause a paused container:
docker unpause <container_id/name>
23. Restart a container:
docker restart <container_id/name>
24. Display Docker disk usage:
docker system df
25. Remove all stopped containers:
docker container prune
26. Remove all unused images:
docker image prune
27. Remove all unused networks:
docker network prune
28. Remove all unused volumes:
docker volume prune
29. Display Docker version information:
docker version
30. Display Docker system-wide information:
docker info
31. Disconnect a container from a network:
docker network disconnect <network_name> <container_id/name>
32. Display Docker usage information including storage and memory:
docker system info
33. Display Docker storage usage by volume:
docker volume df
34. Display detailed information about Docker events in real-time:
docker events
35. Display detailed information about Docker swarm nodes:
docker node ls
36. Display detailed information about Docker services:
docker service ls
37. Create a new Docker service:
docker service create --name <service_name> <image_name>
38. Scale a Docker service to a specific number of replicas:
docker service scale <service_name>=<replica_count>
39. Update a Docker service with a new image or configuration:
docker service update --image <new_image> <service_name>
40. Remove a Docker service:
docker service rm <service_name>
41. Display information about a specific Docker swarm:
docker swarm inspect
42. Join a Docker swarm as a worker or manager:
docker swarm join --token <token> <manager_ip>
43. Leave a Docker swarm:
docker swarm leave
44. Promote a node to be a manager in Docker swarm:
docker node promote <node_id>
45. Demote a manager node to be a worker in Docker swarm:
docker node demote <node_id>
46. Drain a node in Docker swarm to prevent new tasks from being scheduled:
docker node update --availability drain <node_id>
47. Update the configuration of a Docker swarm:
docker swarm update
48. Display detailed information about Docker configs:
docker config ls
49. Create a Docker config:
docker config create <config_name> <file_name>
50. Remove a Docker config:
docker config rm <config_name>
51. Display detailed information about Docker secrets:
docker secret ls
52. Create a Docker secret:
docker secret create <secret_name> <file_name>
53. Remove a Docker secret:
docker secret rm <secret_name>
54. Display detailed information about Docker plugins:
docker plugin ls
55. Install a Docker plugin:
docker plugin install <plugin_name>
56. Upgrade a Docker plugin:
docker plugin upgrade <plugin_name>
57. Remove a Docker plugin:
docker plugin rm <plugin_name>
58. Enable experimental features in Docker:
docker daemon --experimental
59. Display information about Docker network plugins:
docker network plugin ls
60. Configure Docker to use a specific network plugin:
docker network create --driver <plugin_name> <network_name>
Conclusion
In this article, we learned 60 frequently used docker commands. You can bookmark this page to refer to anytime in the future.