Has anyone managed to get Prefect installed into a...
# ask-community
d
Has anyone managed to get Prefect installed into a Docker container for the purpose of building Flows into Docker? I keep running around in circles with the D-in-D problem, my brain is creaking…
s
d-in-d is always a headache, but this pattern works for me (on debian based images):
Copy code
docker run -v $PWD:$PWD -w $PWD -v /var/run/docker.sock:/var/run/docker.sock IMAGE_NAME command
By mapping the $PWD volume, and docker.sock, it allows the Docker instance inside the container to behave as if it was running natively on the Docker host.
t
if you’re relying on the DOCKER_HOST variable to use a remote docker daemon, there’s a fix for that coming that I believe is unreleased yet
d
Thanks for that guys, should have been clearer - the container that I’m installing prefect to is running inside a GitLab container, and whileI can specify it should use the dind service, I can’t get it to actually build the flow into docker. Latest issue is the following: File “/usr/lib/python3.8/site-packages/docker/transport/unixconn.py”, line 43, in connect sock.connect(self.unix_socket) 385 FileNotFoundError: [Errno 2] No such file or directory
So I think I’m doing something fundamentally ass-ways.
t
I believe this could be fixed by that change we made for DOCKER_HOST
d
I really hope so cos I’d love to stop beating my head off it 😂
t
i’m not sure what “i can specify it should use the dind service” means, though
does that mean you’re enabling the container to have access to a remote docker daemon?
d
Ah apologies, yeah let me grab a link that will explain it better than I can…
t
if you could link me to this feature you’re enabling in gitlab, i could look further into it
ah yes perfect thanks!
t
in this container, are you able to start any other docker images?
are you running a docker gitlab container that is spinning up a prefect container that is then building your flow into another docker image?
d
Basically yeah…. my next attempt was to see if I could run any docker commands inside the build/CI/CD container, but in theory I know that using the instructiosn from that link above does allow for building docker images inside a docker container
t
can i see your config?
if you’re using a similar configuration to those docs, it would appear you should be using that container to spin up a prefect container with a mounted docker daemon
(-v /var/run/docker.sock:/var/run/docker.sock )
d
Interesting, I didn’t think I had to do that…. you want the config for my Gitlab job?
Job Description
t
ah ok ok sorry, you’re doing it a different way than I assumed--that is helpful context, thank you
d
Yeah I had a feeling we were looking from different points 🙂 AFAIK, running docker builds inside the type of job config I supplied there should work. But for this specific problem I can’t get it to work…
t
I’m back to my original theory that this is related to DOCKER_HOST
d
Could well be rigth… running a quick test to see if I can do ANY docker build stuff…
Progress at last. The following job config [absolute barebones docker build] works
Untitled
t
can you echo out $DOCKER_HOST?
if i’m right, i should have a workaround for you
d
echo $DOCKER_HOST tcp://docker:2375
t
yep!
we’re right
so here are two things you can do!
1. try running this with a pip install of prefect @ master (this will give you the fix, which hopefully works to resolve this issue but 0.11.0 is not ready for production yet) 2. set base_url in your docker storage to the DOCKER_HOST env var
base_url = os.environ.get("DOCKER_HOST", None)
should do the trick in your docker storage
btw that’s an either/ or… you shouldn’t need to do both
d
Ok cool! I’ll try that now - both items or just one?
Ah, great minds 🙂
🙏 1
Not to sound stupid, but is there a pre-release I need to enable to get that “master”?
pip install prefect@master
, some other syntax?
t
good question
pip install git+<https://github.com/PrefectHQ/prefect.git@master>
i believe this should do the trick
d
Option 1 works, builds like a charm!! Many thanks to you Tyler
I’m having one further problem where it’s trying to find
graphql = "${cloud.api}/graphql/alpha"
and getting an empty value after some variable subsititon but I think that’s my problem
Thanks again!
t
awesome!
is that a problem i can also help with?
d
I'll dig into it some more and get back to you 😁 I did environment variable substitution to get the config.toml to register with a prefect I stance I deployed to aws, and the rest of the substitutions seem to have worked, just need to see why this specific one didn't work 👍
Worked around the graphql problem, something weird going on with the variable substituion… New problem though. As far as I know, once my config.toml is pointed at the right server [my instance on AWS] when it builds and registers I should see it in the UI right?
Untitled
And probably related, I get this as output from the build:
Flow: :/flow/8e6b2c22-f8a2-4de1-a98f-38e998ba1bfc
t
if you register a flow to Server, then yes you should see a Flow in the Server UI
d
Yeah that’s what I see when I register it locally. Guessing it didn’t register onto the remote one then…
t
do you have a cloud account you might have accidentally registered to?
or another server/ a local server?
d
Nope, nothing accessible from there. Curious!
I did a local build/register and THAT one shows up on the remove server. So the server is running and accepting flows, which is good.
👍 1
t
is your UI local?
d
No
t
ah ok cool
so maybe your CI container’s toml is incorrect and is trying to publish to a local server it is running?
d
Any idea why I get that funky looking flow output above? The one missing the first part of the URL?
I’d guess something like that yea..
t
that would appear to be the location of the published flow
since you used a local env, i think it’s saving to that dir
d
But using that same flow and building locally, it registers to the remote service, and I get a usable url for it.. I think I probably have an issue in my toml, as you mentioned. I’ll go away and look again, but it’ll be tomorrow cos it’s late here 🙂 Thanks again for all your help!
t
yes exactly
i’ll be here if you need me!
thanks for ur time today
d
Nah man, thanks for yours, you helped me out of a big freakin hole 😂
🙏 1