We just cannot get the docker deployment to work w...
# prefect-getting-started
a
We just cannot get the docker deployment to work with:
Copy code
if __name__ == "__main__":
    get_repo_info.deploy(
        name="my-first-deployment", 
        work_pool_name="render-work-pool", 
        image=DeploymentImage(
            name="my-first-deployment-image",
            tag="tutorial",
            dockerfile="Dockerfile"
        ),
        push=False
    )
We are getting
docker.errors.DockerException: Error while fetching server API version: request...
Is there any solution for that? It seems to be related to the requests lib version
k
this might seem like a silly question, but do you have docker desktop running?
a
I'm using colima, could that be a problem?
k
ah yeah I'm not familiar with colima at all, sorry
n
@aljaz I'm not familiar with colima directly, but are you able to do something like this?
Copy code
» ipython
Python 3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:38:07) [Clang 16.0.6 ]

In [1]: import docker

In [2]: client = docker.DockerClient.from_env()

In [3]: client.ping()
Out[3]: True
this should be (in a rough / basic sense) what we're trying to do somewhere in
.deploy()
a
Hmm, strange. For some reason I get
ModuleNotFoundError: No module named 'docker'
Eventhough the docker is installed with pip / pip3
Does this console trick require any magic with virtual envs?
n
are you in ipython? ive had global installs of ipython not respect my venv, so i needed a
pip install ipython
and restart the session
a
even with conda I still get
ModuleNotFoundError: No module named 'docker'
n
what does
pip list | grep prefect
show in that same place?
a
Copy code
prefect % pip list | grep prefect
prefect                   2.14.12
prefect-docker            0.4.1
n
ok well it might just be a weird ipython thing on your machine, what about this
Copy code
python -c "import docker; client = docker.DockerClient.from_env(); assert client.ping()"
a
We are getting somewhere! Now it gives
AttributeError: module 'docker' has no attribute 'DockerClient'
btw, is prefect not available in the conda repos?
n
hmm what version is your
docker
install?
a
Copy code
prefect % pip3 show docker
Name: docker
Version: 6.1.3
n
hmm that's the version i have installed where that
python -c
snippet works fine for me 🧐
a
weird... i can connect to docker normally, and it seems to be working fine from the cli
is the requirement to have docker desktop specifically, or is the docker service sufficient?
n
no docker desktop should not be required, i dont know the exact specifics, but any docker engine that would be compatible with docker clients like in the SDK / CLI should work I would think
a
it seems pretty much impossible to get the docker up, so we are starting the question if python is a suitable language for workflow management in the first place
n
> question if python is a suitable language for workflow management in the first place it doesn't need to be for everyone, but we like it at Prefect 🙂 > it seems pretty much impossible to get the docker up are you still trying to use colima? are you using some alt OS?
s
can you also share your
requests
and
urllib3
versions installed and the
python
version you’re on?
a
it seems that we resolved it with:
export DOCKER_HOST="unix://$HOME/.colima/docker.sock"
when using colima
👍 1
it would be great to put this in your docs, as Docker desktop is already out
thank you for your help!
now we are trying to figure out what's the fastest way to build and deploy workflows
If I'm understanding correctly, the Dockerimage file here is required for build and deploying the image:
Copy code
get_repo_info.deploy(
        name="my-first-deployment", 
        work_pool_name="render-work-pool", 
        image=DeploymentImage(
            name="my-first-deployment-image",
            tag="tutorial",
            dockerfile="Dockerfile"
        ),
        push=False
    )
?
n
great to hear you've resolved the colima problem - a docs PR to add an example here would be welcome! otherwise i can do that later and yeah,
.deploy
is the simplest way to programmatically (in contrast to prefect.yaml) create containerized deployments from flows - yep your use of
DeploymentImage
looks valid from what I can see
upvote 1