How to access the filesystem inside Docker containers on Ubuntu 20.04?
Solution 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.
Solution 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.