Darragh

    Darragh

    2 years ago
    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…
    Scott Zelenka

    Scott Zelenka

    2 years ago
    d-in-d is always a headache, but this pattern works for me (on debian based images):
    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.
    Tyler Wanner

    Tyler Wanner

    2 years ago
    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
    Darragh

    Darragh

    2 years ago
    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.
    Tyler Wanner

    Tyler Wanner

    2 years ago
    I believe this could be fixed by that change we made for DOCKER_HOST
    Darragh

    Darragh

    2 years ago
    I really hope so cos I’d love to stop beating my head off it 😂
    Tyler Wanner

    Tyler Wanner

    2 years ago
    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?
    Darragh

    Darragh

    2 years ago
    Ah apologies, yeah let me grab a link that will explain it better than I can…
    Tyler Wanner

    Tyler Wanner

    2 years ago
    if you could link me to this feature you’re enabling in gitlab, i could look further into it
    ah yes perfect thanks!
    Tyler Wanner

    Tyler Wanner

    2 years ago
    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?
    Darragh

    Darragh

    2 years ago
    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
    Tyler Wanner

    Tyler Wanner

    2 years ago
    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 )
    Darragh

    Darragh

    2 years ago
    Interesting, I didn’t think I had to do that…. you want the config for my Gitlab job?
    Tyler Wanner

    Tyler Wanner

    2 years ago
    ah ok ok sorry, you’re doing it a different way than I assumed--that is helpful context, thank you
    Darragh

    Darragh

    2 years ago
    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…
    Tyler Wanner

    Tyler Wanner

    2 years ago
    I’m back to my original theory that this is related to DOCKER_HOST
    Darragh

    Darragh

    2 years ago
    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
    Tyler Wanner

    Tyler Wanner

    2 years ago
    can you echo out $DOCKER_HOST?
    if i’m right, i should have a workaround for you
    Darragh

    Darragh

    2 years ago
    echo $DOCKER_HOSTtcp://docker:2375
    Tyler Wanner

    Tyler Wanner

    2 years ago
    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
    Darragh

    Darragh

    2 years ago
    Ok cool! I’ll try that now - both items or just one?
    Ah, great minds 🙂
    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?
    Tyler Wanner

    Tyler Wanner

    2 years ago
    good question
    pip install git+<https://github.com/PrefectHQ/prefect.git@master>
    i believe this should do the trick
    Darragh

    Darragh

    2 years ago
    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!
    Tyler Wanner

    Tyler Wanner

    2 years ago
    awesome!
    is that a problem i can also help with?
    Darragh

    Darragh

    2 years ago
    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?
    And probably related, I get this as output from the build:
    Flow: :/flow/8e6b2c22-f8a2-4de1-a98f-38e998ba1bfc
    Tyler Wanner

    Tyler Wanner

    2 years ago
    if you register a flow to Server, then yes you should see a Flow in the Server UI
    Darragh

    Darragh

    2 years ago
    Yeah that’s what I see when I register it locally. Guessing it didn’t register onto the remote one then…
    Tyler Wanner

    Tyler Wanner

    2 years ago
    do you have a cloud account you might have accidentally registered to?
    or another server/ a local server?
    Darragh

    Darragh

    2 years ago
    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.
    Tyler Wanner

    Tyler Wanner

    2 years ago
    is your UI local?
    Darragh

    Darragh

    2 years ago
    No
    Tyler Wanner

    Tyler Wanner

    2 years ago
    ah ok cool
    so maybe your CI container’s toml is incorrect and is trying to publish to a local server it is running?
    Darragh

    Darragh

    2 years ago
    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..
    Tyler Wanner

    Tyler Wanner

    2 years ago
    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
    Darragh

    Darragh

    2 years ago
    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!
    Tyler Wanner

    Tyler Wanner

    2 years ago
    yes exactly
    i’ll be here if you need me!
    thanks for ur time today
    Darragh

    Darragh

    2 years ago
    Nah man, thanks for yours, you helped me out of a big freakin hole 😂