Using the `docker diff` command (with examples)
Inspect the changes to a container since it was created
docker diff container
Motivation: Sometimes, it can be useful to see the changes made to a container’s filesystem since it was created. This can help track any modifications or additions that have been made to the container.
Explanation: The docker diff
command is used to inspect the changes to files or directories on a container’s filesystem. When running the command, you need to specify the name or ID of the container you want to inspect. In this case, “container” should be replaced with the actual name or ID of the container you want to examine.
Example output:
C /var/log/nginx/access.log
A /var/log/nginx/error.log
C /etc/nginx/nginx.conf
In this example, the output shows that there have been changes to the access log file and error log file in the /var/log/nginx/
directory, as well as the nginx configuration file (/etc/nginx/nginx.conf
) inside the container.
Display help
docker diff --help
Motivation: When using a command for the first time, or if you need a refresher on the available options and syntax, displaying the help information can be quite helpful. It provides a quick reference for the different commands and their usage.
Explanation: By running docker diff --help
, you can get a list of available options and a brief description of what the command does. The --help
flag is a common convention in command-line interfaces to provide the user with helpful information.
Example output:
Usage: docker diff [OPTIONS] CONTAINER
Inspect changes to files or directories on a container's filesystem
Options:
-a, --all Show all files
-q, --quiet Only display IDs
The command displays the usage of the docker diff
command, along with the available options and their descriptions. In this case, it lists the -a
option to show all files and the -q
option to only display IDs.