If I run a buildah script like this,
ctr=$(buildah from alpine:3) mnt=$(buildah mount "$ctr") ln -sf "$PWD/foo" "$mnt/foo" buildah commit $ctr "myimage"
Will the directory created link outside the container?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
ln -sf "$PWD/foo" "$mnt/foo"
creates a symlink, not a directory; that symlink is created in the
$mnt directory, is named
foo (so it will end up as
/foo in the container image), and stores, as text, a pointer to the current value of
$PWD/foo. The symlink is then stored in the container image, and unpacked as necessary.
Where the link links to depends on when it is dereferenced and by whom. If you access it immediately after creating it, you will access
$PWD/foo in your shell’s current file system namespace. More generally, it will point to whatever
$PWD’s value at the time you ran the command above) is, if anything, in the file system namespace of the process accessing it at the time it is accessed. If it is dereferenced by a process running “in a container”, it will point to
$PWD/foo in the corresponding file system namespace.