Morten Green Hermansen
Morten Green Hermansen

Reputation: 299

Understanding docker diff

I do not understand the output of 'docker diff'. See below for details. This is my Docker version:

$ docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d
OS/Arch (server): linux/amd64

I have a Jenkins image with the following content in /var/jenkins_home:

$ docker run -it --rm jenkins ls /var/jenkins_home
init.groovy.d

I then start Jenkins to populate Jenkins data dir:

$ docker run --name app -d jenkins

After Jenkins is started I call into the container to list the files:

$ docker exec app ls /var/jenkins_home
Download metadata.log
hudson.model.UpdateCenter.xml
identity.key.enc
init.groovy.d
jobs
nodeMonitors.xml
nodes
plugins
secret.key
secret.key.not-so-secret
secrets
updates
userContent

Ok! Lots of new files. Now I want to ask Docker what files are changed or created:

$ docker diff app
C /tmp
A /tmp/hsperfdata_jenkins
A /tmp/hsperfdata_jenkins/1
A /tmp/jetty-0.0.0.0-8080-war--any-
A /tmp/jffi6440203232202129886.tmp
A /tmp/jna--1712433994
A /tmp/winstone874928832634242220.jar
C /var
C /var/log
C /var/log/copy_reference_file.log

So why is it that 'docker diff' isn't showing me the new files in '/var/jenkins_home'? What am I doing wrong?

Best regards, - Morten Green Hermansen, Fanitas

Upvotes: 4

Views: 1222

Answers (1)

Thomasleveil
Thomasleveil

Reputation: 104095

If you take a look at the Dockerfile for the Jenkins image, you will notice that there is a VOLUME directive that makes the location /var/jenkins_home a volume mount point.

As a result, any data written to /var/jenkins_home is stored on the volume mount point, and is not stored on the container filesystem itself.

The docker diff command will only show differences on the container filesystem and won't show anything related to content of volume mount points.

The same applies for other docker commands such as commit, cp and export.

Upvotes: 6

Related Questions