top of page

Docker Diff

The docker diff command is used to inspect changes on the filesystem of a container compared to its base image. It shows the differences in the file system between the container's current state and the state that was committed when the image was created.


Here is the syntax for the docker diff command:

$docker diff <CONTAINER-ID or CONTAINER-NAME>
[root@siddhesh ~]# docker ps
CONTAINER ID        IMAGE                                                                           COMMAND                  CREATED             STATUS              PORTS               NAMES
c7b284035320        nginx@sha256:86e53c4c16a6a276b204b0fd3a8143d86547c967dc8258b3d47c3a21bb68d3c6   "/docker-entrypoin..."   2 days ago          Up 2 days           80/tcp              nginx-service.2.u957m6ksigqwn2n9t8czg11js
414d285e5580        nginx@sha256:86e53c4c16a6a276b204b0fd3a8143d86547c967dc8258b3d47c3a21bb68d3c6   "/docker-entrypoin..."   2 days ago          Up 2 days           80/tcp              nginx-service.3.ya7at6vbakakeayl116rpckni
b8c106f19f04        nginx@sha256:86e53c4c16a6a276b204b0fd3a8143d86547c967dc8258b3d47c3a21bb68d3c6   "/docker-entrypoin..."   2 days ago          Up 2 days           80/tcp              nginx-service.1.h9hv3gspqazdrc94ft2g8lxto
[root@siddhesh ~]# docker diff c7b284035320
C /run
A /run/nginx.pid
D /run/secrets
C /var
C /var/cache
C /var/cache/nginx
D /var/cache/nginx/client_temp
D /var/cache/nginx/fastcgi_temp
D /var/cache/nginx/proxy_temp
D /var/cache/nginx/scgi_temp
D /var/cache/nginx/uwsgi_temp
[root@siddhesh ~]#

Here's a brief explanation of the output:


A: Added file or directory

C: Changed file or directory

D: Deleted file or directory


Note that the docker diff command only works on a running container. If you want to inspect changes in a stopped container, you may need to commit the container first to create a new image and then inspect the changes in that image.

1 Comment

Rated 0 out of 5 stars.
No ratings yet

Add a rating
Guest
Nov 19, 2023
Rated 5 out of 5 stars.

👌

Like
bottom of page