Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

The Docker diff command

The Docker diff command

Docker Command ReferenceDocker Command Reference


docker diff This command is used to display changes in a Docker container's filesystem. It shows all modifications that have occurred since the container was created, including files or directories that were added, deleted, or modified.

docker diff This command is very useful for debugging and understanding filesystem changes in a container.

Syntax

docker diff CONTAINER

docker diff The command's output contains the following three types of changes:

View a container's filesystem changes


docker diff my_container

Display the filesystem changes of the container named my_container.

Example

Start a container and modify the filesystem:


docker run -d --name my_container ubuntu bash -c "echo 'Hello, Docker!' > /hello.txt && sleep 3600"

View the container's filesystem changes:


docker diff my_container

Example output:


A /hello.txt

This output indicates that the /hello.txt file was added to the container filesystem.

Delete a file in the container:


docker exec my_container rm /hello.txt

View the container's filesystem changes again:


docker diff my_container

Example output:


D /hello.txt

This output indicates that the /hello.txt file was deleted from the container filesystem.

Notes

docker diff This command is a powerful tool for displaying changes to a Docker container's filesystem. By using it, users can easily view and understand the filesystem changes made to a container since its creation, helping with debugging, auditing, and analyzing container behavior.


Docker Command ReferenceDocker Command Reference