Useful Docker Commands (Docker Cheat Sheet)

Engineer, Tech Lead and Technopreneur

Here are some useful Docker commands.

1. How to list Docker images

docker images


2. How to run and get the terminal of Docker instance

docker  run -i -t <docker_image_id> /bin/bash


3. How to remove Docker image

docker rmi <image_id>


4. Show running containers in use 

docker ps


5. Show all containers

docker ps  -a


6. Stop all containers

docker stop $(docker ps -a -q)


7. Remove all containers

docker rm $(docker ps -a -q)


8. Create and run Ubuntu container

docker run -i -t ubuntu /bin/bash


9. Create and run Centos container

docker run -i -t centos /bin/bash


10. Create a new image from a container’s changes (commit)

docker commit <container_id> <name>


1,054 total views, 4 views today

 

Feel Free to ask questions and share your thoughts