0

I need to access a file system of a docker image, but when I use the path /var/lib/docker this is what I get

buildkit/   containers/ image/      network/    overlay2/   plugins/    runtimes/   swarm/      tmp/        trust/      volumes/

I can't find aufs, so how can I access the file sys of any docker images ?

1
  • 2
    By default, Docker now uses the overlay2 filesystem over the images. But try and explain your usecase: Why do you need to access the filesystem inside the containers? If you describe your usecase, it's easier to give you the best solution. Oct 29, 2021 at 14:19

2 Answers 2

2

In additon to MaestroGlanz' answer, you can also export an entire filesystem of a Docker container to a .tar archive:

user@machine $ docker export --output="container-name.tar" <container-name>

And to reiterate again, if you need persistent access to some files or folders inside a container, it might be a good idea to map them directly when starting the container, like this:

user@machine $ docker run -d -v /path/to/data:/data <container-name>

This will map the directory /data inside the container to the directory /path/to/data on your local filesystem.

1

Normally, you can't find your container's files on your hard drive. If you want to browse the files, you need a shell inside the container:

user@machine $ docker exec - it <container-name> /bin/bash

If you want to access the file, best is to copy it from the container with

user@machine $ docker cp <container-name>:/path/to/file /target/path/

If you want to access the real file, you have to mount the file into the container on creation.

2
  • This is incorrect, dockers volume information is absolutely stored on the host file system (usually under /var/lib/docker/volumes). One shouldn't go poking about in the system files but regardless, it is incorrect to say you cant find them on the hard drive.
    – miversen33
    Apr 27, 2022 at 2:14
  • @miversen33 Then extract a file from the image. Language is communication. I think, it is pretty clear to the person, that was asking the question, that they are somehow stored on the file system. But not in the way, that you can find them in the way of accessing them. Apr 27, 2022 at 6:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.