#Dagger SDK FastAPI

1 messages · Page 1 of 1 (latest)

sullen dragon
#

The Dagger SDK is trying to start its own engine by running Docker, but the Docker executable isn’t available in my FastAPI container. I am running Dagger Engine in a separate container but I am unable to connect the FastAPI container to the Dagger Engine container.

limber mantle
sullen dragon
#

Hi @limber mantle. Yes, I am creating a Dagger client connection in my containerized Python FastAPI. I have also tried the env var. I even tried using Cursor with agents and it kept trying things until it ran out of options and created a TROUBLESHOOTING.md. The plan is to use Dagger for the AI logic of the app, much like LangChain etc.

limber mantle
#

Cc @thick ruin in case there is something tricky here

sullen dragon
#

@limber mantle Are there any demo projects that use the Dagger SDK and an API framework like FastAPI?

limber mantle
#

We were daggerizing a FastAPI project the other day, but that was to give build, test, etc workflows to the app.

Sounds like you want to present an api that calls dagger in the backend?

chrome lark
#

@sullen dragon you might find these docs helpful:

https://docs.dagger.io/configuration/custom-runner/

it sounds like you are embedding the client into your fastapi application? If that’s the case you need to configure the client to talk to the other container like in the docs above

solid raptor
#

lmk if you need any help with it

chrome lark
#

This is how I deployed Dagger for a hosting platform (in the api with a remote runner). I can try to whip something up for an example if it’s helpful

sullen dragon
#

@chrome lark Thanks for sharing. Let me check if I missed something and I’ll report back. An example is always helpful.

#

@solid raptor Thanks for sharing, I am looking into it.

#

@limber mantle Thanks for the prompt response.

thick ruin
# chrome lark <@997616161531367434> you might find these docs helpful: https://docs.dagger.io...

Yeah @sullen dragon, Jason is on point. ☝️ You need to provision the Dagger engine outside your FastAPI container however is best for you, then give it access in the FastAPI container. There's a couple env vars you need other than _EXPERIMENTAL_DAGGER_RUNNER_HOST. You'll need the port and token to connect to it. When you establish a client connection with the Python SDK, it's only when port and token are missing that it tries to provision the engine for you. You can also let the Python SDK download the Dagger CLI and create that session since it's starting the engine itself that's probably more problematic for you.

chrome lark
#

Hi @sullen dragon, I made an example repo, with a docker compose customer runner and a go application (should work similarily with Python) showing you how to embed Dagger into an application and connect to the runner over TCP (not secure just an fyi). Here is also a quick screen recording of the application in action. Here is the link to the repo with the code: https://github.com/jasonmccallister/dagger-embedded-go-api

Hopefully this helps, have a great weekend