Docker Sample Command with Example
docker ps: lists running Docker containers
Example: docker ps – lists all running containers
docker images: lists Docker images that have been pulled or built
Example: docker images – lists all available images on the system
docker pull: downloads a Docker image from a registry
Example: docker pull ubuntu – downloads the latest Ubuntu image from the Docker Hub registry
docker build: builds a new Docker image from a Dockerfile
Example: docker build -t myimage:1.0 . – builds a new image named “myimage” with tag “1.0” using the Dockerfile in the current directory
docker push: uploads a Docker image to a registry
Example: docker push myregistry/myimage:1.0 – uploads the “myimage” image with tag “1.0” to the “myregistry” registry
docker stop: stops a running Docker container
Example: docker stop mycontainer – stops the container with the name “mycontainer”
docker rm: removes a Docker container
Example: docker rm mycontainer – removes the container with the name “mycontainer”
docker rmi: removes a Docker image
Example: docker rmi myimage:1.0 – removes the “myimage” image with tag “1.0”
docker exec: runs a command in a running Docker container
Example: docker exec -it mycontainer /bin/bash – opens a Bash shell inside the running container with the name “mycontainer”