I am new to docker and begin playing with it. I have created a few images from committing a few changes. Started with
sudo docker run -i -t ubuntu /bin/bash
doing a few installs, exited and did
sudo docker commit -m="my first message" innocent_dockernovice sandbox/yves:s1
and repeting the process
sudo docker run -i -t sandbox/yves:sN /bin/bash
doing stuff in shells, exiting and
sudo docker commit -m="what I did in step N" happy_dockeruser sandbox/yves:sN+1
Now I want to go back to a previous step image and would like to list all the messages doing a sudo docker image -m
kind of command similar to a git log
one. What is the best way to do it?
Docker's commit command allows users to take a running container and save its current state as an image. This means to add our new user, we will need a running container. To get started, let's go ahead and launch a Redis container with the docker run command.
It can be useful to commit a container's file changes or settings into a new image. This allows you to debug a container by running an interactive shell, or to export a working dataset to another server. Generally, it is better to use Dockerfiles to manage your images in a documented and maintainable way.
The storage location of Docker images and containersUbuntu: /var/lib/docker/ Fedora: /var/lib/docker/ Debian: /var/lib/docker/ Windows: C:\ProgramData\DockerDesktop.
You can view commit messages by using docker inspect on the commit hash displayed afterwards. To view more of them you must do it recursively.
$ docker commit -m "added test file" sick_morse
61efdbd141dc5fb1c289ed5151f3ce7b5985a5829bd92ba322ad6061cb1eee21
$ docker inspect 61efdbd141dc5fb1c289ed5151f3ce7b5985a5829bd92ba322ad6061cb1eee21 | grep added
"Comment": "added test file",
Found info here
This would let you view the messages for the top 3 most recent comments.
$ docker images -a --no-trunc | head -n4 | grep -v "IMAGE ID" | awk '{ print $3 }' | xargs docker inspect | grep Comment
To make things simple, i did a simple bash script in github gist: docker-log
#!/usr/bin/env bash
DOCKER=`which docker`
if [ "$#" -ne 1 ]; then
echo "Usage: $0 IMAGE"
exit 0
fi
for commit in $($DOCKER history $1 | sed 1d | awk '{ print $1 }')
do
content="$commit
$($DOCKER inspect $commit | tr -d '\"' | grep 'Created\|Author\|Comment')"
echo "$content"
done
Snapshot for usage:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With