#Mounting docker socket to dagger Container

1 messages Β· Page 1 of 1 (latest)

raw kindle
#

Description

I need to run a container that needs to run a nested conatiner inside. What is the best approach?

What I have tried so far

I was looking in the sdk and there is a Socket type. However cannot use it because if i set it as an input in my function then I get the following error message failed to get field spec: failed to decode default value for arg "socket": decode "Socket" ID: cannot decode ID from "unix:///var/run/docker.sock": illegal base64 data at input byte 4

As an alternative I also tried using Host().UnixSocket(...) but as expected won't work because access to Host object has been removed in last release.

slim sluice
#

Hey @raw kindle πŸ‘‹ ,
Could you share a snippet of your code, please?

#

Did you try the method WithUnixSocket that forwarded to the given Unix socket path?

dull stratus
# raw kindle ## Description I need to run a container that needs to run a nested conatiner i...

hey there! it's not possible currently. You can follow this issue for future updates: https://github.com/dagger/dagger/issues/6747

GitHub

Right now you can't invoke Functions that accept args of type Socket from the CLI. In theory, this should be as simple as supporting e.g. dagger call fn --sock unix:///var/run/docker/docker.soc...

forest stirrup
#

^^ This works great for me, I also have an example of docker in docker and podman in docker for dagger if you would like

dull stratus
#

hey @raw kindle ! just realized that I haven't answered your question entirely. You can run containers in Dagger by spawning Docker, Podman, etc inside a Dagger pipeline as Nic is correctly pointing out. What you can't do for the moment is to pass your own machine's docker engine unix socket to the Dagger pipeline which will be address in the issue that I posted above

#

If you need some additional help with Nic's approach, we're here to help πŸ™Œ

raw kindle
raw kindle
dull stratus
raw kindle
#

Managed to make it work, thanks @forest stirrup and @dull stratus πŸ˜„

lavish trail
#

hey @raw kindle would you mind sharing your approach to get it solved? I've a similar issue when running buildpacks (pack cli) on dagger

raw kindle
lavish trail
#

Thanks for sharing, I've been testing sharing the socket but since Host is not avaible in function context this looks pretty good.