I would like to take a Docker image (let's say ubuntu:latest) and make something like:
> docker-image-mount ubuntu:latest my_little_ubuntu
> cd my_little_ubuntu
> ls
/usr /var /bin etc.
Is it possible somehow?
The -v flag is used to mount a host folder, and it consists of two fields separated by a colon. The first part is the path in the host machine. The second part is the path in the container. The --name flag (optional) is used to give the container a specific name.
Basically, there are 3 types of mounts which you can use in your Docker container viz. Volumes, Bind mount and tmpfs mounts.
With Bind mounts Docker mounts the given source directory into a location inside the container. (The original directory / file in the read-only layer inside the union file system will simply be overridden).
You could use Podman and Buildah to mount a container image (RW).
prompt:~ # podman pull ubuntu
prompt:~ # container=`buildah from ubuntu`
prompt:~ # echo $container
ubuntu-working-container
prompt:~ # mnt=`buildah mount $container`
prompt:~ # echo $mnt
/var/lib/containers/storage/overlay/2b1...09b/merged
prompt:~ # ls $mnt
bin boot dev etc home lib ... usr var
prompt:~ # buildah umount $container
If you actually want to mount a running or stopped container, you could mount it using the podman mount
command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With