#container directory entries not showing mounted files

1 messages · Page 1 of 1 (latest)

strong swift
#

Hi dagger community!

I'm running the following dagger cli command:
touch file.txt;dagger core container from --address=debian:trixie-slim with-exec --args="mkdir","/project" with-mounted-file --path="/project/file.txt" --source="file.txt" directory --path="/project" entries

I would expect the mounted file file.txt as an output of entries dagger cli command but it returns that is empty.

I checked that the file is in the container.
I tested with a mounted directory and it retrieves the mounted files from it.

It seems a bug to me, am I missing something?

opaque dragon
strong swift
#

Hi @opaque dragon !

Thank you for the answer. I can switch to with-directory and with-file then.

Maybe it is not the thread, but is it there any documentation about the differences between them?

Considering that the mounting happens inside the dagger container I don' t understand why I would prefer mounting over copying.

opaque dragon
# strong swift Hi <@336241811179962368> ! Thank you for the answer. I can switch to `with-dire...

hey @strong swift not super well documented sorry. Here's an issue about this (https://github.com/dagger/dagger/issues/10060) cc @spice garnet

GitHub

What is the issue? There is much confusion for new users around with-mounted-directory, with-mounted-file vs with-directory, with-file. We often see these questions in Discord. We should doco it an...

#

in summary, it's the same difference when using a Dockerfile as follows:

Using with-file

FROM $image

COPY foo.txt /projects/foo.txt

RUN $command

Using with-mounted-file

FROM $image

RUN --mount=type=bind,source=foo.txt,target=/projects/foo.txt $command

^ this las option is convenient when you don't want the file to be present in the file image it's only "mounting" the file during the execution of the steps but it won't be persisted in the underlying Container once/if gets pushed to a registry 🙏

spice garnet
opaque dragon
strong swift
#

@opaque dragon it makes sense if you want to publish the generated container image. It's still strange that the entries of a mounted directory are shown, but not the ones of a file. However, I'm fine with the current response.
Thank you!

opaque dragon
# strong swift <@336241811179962368> it makes sense if you want to publish the generated contai...

It's still strange that the entries of a mounted directory are shown,

this happens because when you mount a complete directory, buildkit already knows about it as it had to upload it to the engine so it can return whatever files it has in there. On the contraty, when you do a with-mounted-file within a standard container directory, what you end up with is a combination of the base container directory (/projects on your case) plus a new mounted file which doesn't become part of the resulting image. That's the reason why calling entries on that direcrory, will only show the resulting files that are part of the final image and not the mix of the two

strong swift
#

@opaque dragon , thank you for the full response!

spice garnet