Docker Commands Cheat sheet

March 06, 2020 | 1 comment

Docker Commands Cheat sheet

Docker is very popular for developing applications and sharing them faster. Docker has number of commands to achieve tasks. In this article we will follow some common docker commands that we need everyday. For reference we are using Docker 19.03.5 Docker arranges the commands in two groups Management Commands and sub commands. This is true for docker 1.13 and later. With this kind of organization it is easy to navigate the commands based on the functional area of docker.

Working with Image

List Image
To see list of docker images run the following command
docker image ls 
Build Image
To build an image run the following command
docker image ls
Save Image
Save image is used to save an Image not a container. For example to save the docker image bootng-sample to test.tar run the following command
docker image save bootng-sample > test.tar
Tag Image
Docker tag is an alias for an image which is more readable and meaningful than the ID of the image. For example to tag an image with id "ID" with name "docker_tag_name" we can run the following command.
docker image tag "ID" "docker_tag_name"
Remove a docker image
To remove a docker image execute the rm command and specify the id or tag of the image
docker rm "ID"

Containers related

List Containers
To see containers running or stopped use the following command. By default it shows only the running containers to see all the containers use the flag --all docker container ls --all
docker container ls
docker container ls --all
List only containers Id's
To list only the container ids use flag --quiet or -q
docker container ls -q
List only latest containers
To list only latest container use the flag --latest or -l
docker container ls --latest
Stop Containers
To stop one of more containers use the following command
docker container stop CONTAINER_ID
Start Containers
To start one of more containers use the following command
docker container start CONTAINER_ID
Rename Containers
To rename container use the following command
docker container rename OLD_NAME NEW_NAME
See logs from the Containers
To see logs from the container use the following command
docker container logs CONTAINERID

1 comment :

Please leave your message queries or suggetions.