In this article i am expected to give you few commands that are frequently required and used when building, shipping and running docker images and containers.
Checking the docker version
docker -v OR docker --version
Get currently running containers (only the active containers)
Get all containers ( all running + stopped)
docker ps -a
Get a list of images available
docker rmi <image-id>
Start/run a container
docker run <image-name>
Start the Stopped Container
docker start <container-id>
stop running container
docker stop <container-id>
Get the last created container
docker ps -l
Go to the bash mode of the running container
docker exec -it <running-container-name> bash
Get IP Address of the docker container
docker inspect <container-id>
Show docker disk usage
This will display the disk usage of the docker.
docker system df
See a list of volumes
docker volume ls
Remove a volume
docker volume rm <volume-name>
Volumes can be used by one or more containers, and take up space on the Docker host. Volumes are never removed automatically, because to do so could destroy data.
$ docker volume prune WARNING! This will remove all volumes not used by at least one container. Are you sure you want to continue? [y/N] y
By default, you are prompted to continue. To bypass the prompt, use the
By default, all unused volumes are removed. You can limit the scope using the
--filter flag. For instance, the following command only removes volumes which are not labelled with the
$ docker volume prune --filter"label!=keep"