Docker diff command

Docker command reference


docker diffThis command is used to display changes to the Docker container's file system. It shows all modifications made to the file system since the container was created, including added, deleted, and modified files or directories.

docker diffThe command is very useful for debugging and understanding container file system changes.

Syntax

docker diff CONTAINER
  • CONTAINER: The name or ID of the container.

docker diffThe output of the command includes the following three types of changes:

  • AIndicates newly added files or directories.
  • DIndicates deleted files or directories.
  • CIndicates modified files or directories.

View container file system changes

docker diff my_container

Display the file system changes for the container named my_container.

Example

Start a container and modify the file system:

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

View the container's file system changes:

docker diff my_container

Output example:

A /hello.txt

This output indicates that the /hello.txt file was added in the container file system.

Delete a file in the container:

docker exec my_container rm /hello.txt

View the container's file system changes again:

docker diff my_container

Output example:

D /hello.txt

This output indicates that the /hello.txt file was deleted in the container file system.

Notes

  • docker diffThis command only shows changes to the container's file system, not other status information within the container (such as running processes).
  • The output information may continuously change due to file system changes inside the container, so it should be checked promptly when needed.

docker diffThe command is a powerful tool for displaying changes in Docker container file systems. By using this command, users can easily view and understand file system changes made to a container since its creation, which aids in debugging, auditing, and analyzing container behavior.


Docker command reference

other extensions