Essential Docker Commands
Here are 15 basic commands that every Docker user should know:
1. Docker Version
: This command displays the version number of Docker that is currently installed on your system.
Docker Version
2. Docker Info
: This command displays the detailed information about Docker, including the number of containers, images, and memory usage.
docker info
3. Docker Images
: This command lists all the images available on your Docker system.
Docker Images
4. Docker Pull
: This command downloads a specified image from Docker Hub or any other repository to your local system.
Docker Pull
5. Docker Run
: This command starts a new container with the specified image.
docker run [image-name]
6. Docker Ps
: This command lists all the running containers on your system.
Docker Ps
7. Docker Stop
: This command stops a running container.
docker stop [container-name]
8. Docker Start
: This command starts a stopped container.
docker start [container-name]
9. Docker Restart
: This command restarts a running container.
docker restart [container-name]
10. Docker RM
: This command removes a container from the system.
docker rm [container-name]
11. Docker Rmi
: This command removes an image from the system.
docker rmi [image-name]
12. Docker Exec
: This command allows you to execute commands in a running container.
docker exec [container-name] [command]
13. Docker Build
: This command builds an image from a Dockerfile.
docker rmi [image-name]
12. Docker Exec
: This command allows you to execute commands in a running container.
docker exec [container-name] [command]
13. Docker Build
: This command builds an image from a Dockerfile.
docker build [path-to-dockerfile]
14. Docker Commit
: This command creates a new image from a container’s changes.
docker commit [container-name] [image-name]
15. Docker Login
: This command logs you into Docker Hub or any other registry.
docker login [registry-name]
These are the most commonly used Docker commands that every user should know. These commands will help you get started with it quickly and easily.
Now that you have a basic understanding of how to use some of the most common commands in Docker, let’s take a look at another important tool in the world of container orchestration: Kubernetes.
Kubernetes is a popular open-source container orchestrator that helps to deploy, scale, and manage many microservices. It uses a configuration file to automate the container management.
Major Commands in Kubernetes
1. kubectl create
: This command creates a new resource in the cluster, such as a deployment, pod, or service.
kubectl create -f [filename]
2. kubectl get
: This command retrieves information about resources in the cluster, such as pods, services, and nodes.
kubectl get [resource-type]
3. kubectl describe
: This command provides detailed information about a specific resource, such as its state, events, and specifications.
kubectl describe [resource-type] [resource-name]
4. kubectl apply
: This command updates existing resources in the cluster or creates new ones if they don’t exist.
kubectl apply -f [filename]
5. kubectl delete
: This command deletes a resource from the cluster.
kubectl delete [resource-type] [resource-name]
6. kubectl logs
: This command retrieves logs for a specific pod.
kubectl logs [pod-name]
7. kubectl exec
: This command opens a shell inside a running container in a pod.
kubectl exec -it [pod-name] -- [command]
8. kubectl scale
: This command changes the number of replicas for a deployment.
kubectl scale deployment [deployment-name] --replicas=[number-of-replicas]
8. kubectl rolling-update
: This command updates an application with zero downtime by gradually replacing old pods with new ones.
kubectl rolling-update [deployment-name] -f [new-deployment.yaml]
9. kubectl port-forward
: This command forwards traffic from a local port to a port in a pod.
kubectl port-forward [pod-name] [local-port]:[pod-port]
These are some of the major commands in Kubernetes that every user should know. With these commands, you can easily manage your applications and resources in a Kubernetes cluster.
Conclusion
In conclusion, both Docker and Kubernetes are important tools for managing containers and deploying applications. Docker is a platform for building, shipping, and running containers, while Kubernetes is a platform for automating deployment, scaling, and operations of containerized applications. Whether you are a beginner or an experienced user, these commands will help you to simplify your workflow and achieve your goals.
Stay tuned for our next post where we will provide a complete guide on how to use these commands and work with both Docker and Kubernetes. This guide will walk you through each command in detail and provide practical examples to help you get started with using these powerful tools for container orchestration.