Skip to content

negrel/ocimount

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OCIMount - Mount OCI/Docker images.

OCIMount is a tool to mount OCI/Docker image easily.

Getting started

Let's start by installing ocimount.

Installation

go install github.com/negrel/ocimount@latest

Usage

# Print help informations
ocimount --help

Mount an image as read-only:

anegrel$ ocimount mount archlinux:latest
INFO[0000] failed to get store, trying again in unshare mode.
ERRO[0000] failed to mount "archlinux:latest": chown /var/home/anegrel/.local/share/containers/storage/overlay/l: operation not permitted

# Oops, it seems that we can't access the storage.
# Let's enter image modified user namespace:
anegrel$ ocimount unshare

root# ocimount mount archlinux:latest
INFO[0000] "docker.io/library/archlinux:latest" successfully mounted at "/var/home/anegrel/.local/share/containers/storage/overlay/de3fc361158be7fbfc230f523b9df392bcf95cba5cf88141292374bf1ec7d2a7/merged".
/var/home/anegrel/.local/share/containers/storage/overlay/de3fc361158be7fbfc230f523b9df392bcf95cba5cf88141292374bf1ec7d2a7/merged

# That's it, out image is mounted read-only.
# Mountpoint is always print to stdout.

You can then unmount the image using umount command.

NOTE: Checks the --overlay and --bind flags to mount an image as writable and to a custom mountpoint.

Testing

This code is widely untested, nevertheless it should be harmless as we're only reading from the container store and performing some mount syscall.

Contributing

If you want to contribute to ocimount to add a feature or improve the code contact me at negrel.dev@protonmail.com, open an issue or make a pull request.

🌠 Show your support

Please give a ⭐ if this project helped you!

buy me a coffee

📜 License

MIT © Alexandre Negrel