Everything is a file, but tmpfs) identically./app/data.txt) is just a human-readable label.
1
echo "Important Data" > original.txt
1
2
3
4
# Create a Hard Link (Direct reference to inode)
ln original.txt hard.txt
# Create a Soft Link (Reference to path)
ln -s original.txt soft.txt
1
ls -li *.txt
original.txt and hard.txt have the identical number.soft.txt. It has a different number, and explicitly points -> original.txt.
1
2
3
rm original.txt
cat hard.txt # SUCCEEDS: Data still exists because Inode ref count > 0
cat soft.txt # FAILS: "No such file or directory"
/home/user/data) to the Container (/app)./var/lib/docker/volumes/).whiteout items from the read-only layer if they are modified in the writable layer.docker info and identify your Docker’s Storage Driver overlay2 storage driver by default.Layered storage: Each Docker image is built from multiple layersRead-only base layers: Image layers are immutable and shared between containers.Writable container layer: Any changes made in a running container occur in this topmost layer.Copy-on-Write (CoW): When a file in a lower layer is modified, it is copied to the writable layer.LowerDir).LowerDir up to UpperDir.UpperDir.mount --bind Syscall/home/user/project).
1
2
3
docker volume create myrepo
docker volume ls
docker volume inspect myrepo
point1 and point2 in interactive modepoint1 is an alpine container and will mount myrepo as directory /point1 v represents the mount of the volume myrepo to /point1.
1
docker run -it --name point1 -v myrepo:/point1 alpine sh
the_ram_was_here inside /point1.point2 is an alpine container and will mount myrepo as directory /point2
1
docker run -it --name point2 -v myrepo:/point2 ubuntu sh
the_ram_was_here exists inside /point2 v flag, but the part in front of the : should now point to a directory.my_host_repo in the current directory.realpath command to get the full path to my_host_repo (Linux/Mac only).alpine image and mount the new directory to a directory called /from_host using the v flag. /from_host
1
2
3
4
5
6
mkdir my_host_repo
realpath my_host_repo
docker run -it -v /Users/lngo/my_host_repo:/from_host alpine sh
cd /from_host
touch test
exit
my_host_repo directory.ubuntu image and mount the new directory to a directory called /from_host using the v flag. /from_host directory also contains the test file.
1
2
3
4
docker run -it -v /Users/lngo/my_host_repo:/from_host alpine sh
cd /from_host
ls
exit
--tmpfs flag specifies the setup of the tmpfs mount, with permission, size, and management mode.df -h to check that your mount is available inside the container.
1
2
3
docker run -it --tmpfs /tmpfs:rw,size=1g,mode=1777 ubuntu sh
df -h
exit
/app server.js file inside the host directory and use the nodejs container to test:
1
2
cd /app
node server.js
1
2
3
echo "This is physical evidence" > host_evidence.txt
ls -i host_evidence.txt
# Example Output: 123456 host_evidence.txt
1
docker run -it -v $(pwd)/host_evidence.txt:/container_evidence.txt ubuntu:20.04 bash
1
2
ls -i /container_evidence.txt
# Output: 123456 /container_evidence.txt