Inspect docker container FS changes from host

I’ve started a docker container and I’ve modified a file. At some point later I’d like to inspect this change from the docker host. Now I use docker cp to export the file, inspect it, delete it. But this multistep copy-read-delete process seems like over kill if I just want to read a file.

Is there a better way to inspect filesystem changes in a docker container?

  • Docker images Ubuntu 14.04 not connected internet
  • Rancher can't find link when net=host
  • Running Scrapy in a docker container
  • ffmpeg failed - 455 Method Not Valid in This State
  • Docker launch 2 processes in the conatiner
  • Is it possible to turn Docker image into Windows executable for easy distribution?
  • I need more info than docker diff is showing.

  • Why is my docker machine not working under OSX?
  • Why does docker stop immediately after starting and how to prevent it from stopping?
  • Creating a new PostgreSQL user in Dockerfile
  • dante-sever fail to bind ip by interface name in docker container
  • Docker on AWS filling up its thin pool while running somehow?
  • single host multi container v.s. multi host single container
  • 2 Solutions collect form web for “Inspect docker container FS changes from host”

    You can find the filesystem of a running container the Docker data directory, usually /var/lib/docker/. The specific location varies depending on which storage driver is used. In the case of AUFS, the location is `/var/lib/docker/aufs/mnt/${CONTAINER_ID}/.

    $ HELLO_WORLD=$(docker run -d  ubuntu:12.04 /bin/sh -c "while true; do echo Hello world; sleep 1; done")
    $ docker ps
    CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES
    2524e196adf0        ubuntu:12.04        /bin/sh -c while tru   4 seconds ago       Up 3     seconds                            naughty_brown
    $ echo $HELLO_WORLD
    $ sudo ls /var/lib/docker/aufs/mnt/${HELLO_WORLD}/
    bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  selinux  srv  sys  tmp  usr  var

    This is not a general solution, but in special cases, you can use mounted volumes:

    Start the container with volume:

    sudo docker run -v /host_path/shared:/shared <container>

    Store files you want to inspect in container dir /shared or copy & ln files to /shared and make needed files symbolic links to files stored in /shared.

    cp /mydir/myfile /shared/myfile
    ln -s -f /shared/myfile /mydir/myfile

    Then you can inspect these files directly in /host_path/shared.

    Note: You cannot symbolic-link special files like /etc/passwd, /etc/hostname etc.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.