Skip to content

Commit eae3aef

Browse files
author
Sengorius
committed
added a "docker images" shortcut like "the old way"
1 parent 31b5a57 commit eae3aef

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

.env.template

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,10 @@ export NETWORK_NAME=proxy-network
3636
# tell "DockerExec do ps" what columns to print out; separate with a pipe
3737
# possible values are: ID, Image, Command, CreatedAt, RunningFor, Ports,
3838
# State, Status, Size, Names, Labels, Mounts and Networks
39-
# see https://docs.docker.com/engine/reference/commandline/ps/#formatting
39+
# see https://docs.docker.com/reference/cli/docker/container/ls/#format
4040
export DOCKER_PS_COLUMNS="Image|Status|Ports|Names"
41+
42+
# tell "DockerExec do images" what columns to print out; separate with a pipe
43+
# possible values are: ID, Repository, Tag, Digest, CreatedAt, CreatedSince, Size
44+
# see https://docs.docker.com/reference/cli/docker/image/ls/#format
45+
export DOCKER_IMAGES_COLUMNS="Repository|Tag|Size|CreatedSince"

DockerExec

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ if [[ "help" == "$ACTION" || "--help" == "$ACTION" || "-h" == "$ACTION" ]]; then
121121
echo
122122
echo -e " ${COLOR_GREEN}do${COLOR_WHITE}: Other tools"
123123
echo -e " ${COLOR_BLUE}ps${COLOR_WHITE} - lists all containers like 'docker ps -a'"
124+
echo -e " ${COLOR_BLUE}images${COLOR_WHITE} - lists all local images like 'docker image ls -a'"
124125
echo -e " ${COLOR_BLUE}remove${COLOR_WHITE} - does a 'docker rm' to all containers that have stopped running"
125126
echo -e " ${COLOR_BLUE}cleanup${COLOR_WHITE} - deletes all docker images, that have a <none> as tag name or image id"
126127
echo -e " ${COLOR_BLUE}finish${COLOR_WHITE} - stops and removes all current containers, like 'docker stop && docker rm'"
@@ -562,6 +563,14 @@ elif [[ "do" == "$ENVIRONMENT" ]]; then
562563

563564
docker ps -a --format "$PS_FORMAT"
564565

566+
elif [[ "images" == "$ACTION" ]]; then
567+
IMAGES_COLUMNS=${DOCKER_IMAGES_COLUMNS:-Repository|Tag|Size|CreatedSince}
568+
IMAGES_COLUMNS=${IMAGES_COLUMNS//|/ }
569+
IMAGES_COLUMNS_FORMATTED=$(join_by '}}\t{{.' $IMAGES_COLUMNS)
570+
IMAGES_FORMAT="table {{.$IMAGES_COLUMNS_FORMATTED}}"
571+
572+
docker images --all --format "$IMAGES_FORMAT"
573+
565574
else
566575
print_error "Unknown option '$ACTION'..." 1
567576
exit 1

0 commit comments

Comments
 (0)