Score:0

How to access the filesystem inside Docker containers on Ubuntu 20.04?

in flag

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 ?

Artur Meinild avatar
vn flag
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.
Score:2
vn flag

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.

Score:2
in flag

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.

miversen33 avatar
ph flag
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.
MaestroGlanz avatar
in flag
@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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.