Useful Docker CLI Commands
There are a lot of docker commands, here we’ll look at the most commonly used ones
- docker run <image-id>: This command is used to start a new container from an image.
- docker ps: Lists all running containers.
- docker ps -a: Lists all containers, both running and stopped.
- docker stop <container id>: Stops a running container.
- docker rm <container id>: Removes a container.
- docker images: Lists all images on the local system.
- docker rmi <image id>: Removes an image.
- docker pull <image>: Pulls an image from a registry.
- docker build -t <image-name>. : Builds an image from a Dockerfile in the current directory.
- docker exec -it <container-id> bash: Runs a bash shell in a running container.
- docker logs <container-id>: Shows the logs of a container.
Docker CLI vs Docker Desktop
Docker is an open-source platform. It is used to containerize applications. This is done by packaging applications along with their dependencies into containers that can be easily deployed. Users interact with Docker primarily using either the Docker CLI or the Docker Desktop Application.
In this article, we’ll be looking into each one in detail and then understanding their similarities and differences.