How to pull and run a docker image from a registry?

I have a gitlab registry with some docker images that I want to run using prefect 2.0

When I try to run the following, I get an error

reg = docker.DockerRegistry(username=user, password=pw, registry_url="")
b = docker.DockerContainer(image_registry = reg, command=["run"],  image=image_tag)

I get a 404 Client Error: Not Found for url: http+docker://localhost/v1.41/images/create?tag=latest&fromImage=0d191eb865749afb42ebdfd700a2a975c1f20b95. The thing is this url seems very wrong to me… I would have though it was something like

This is the traceback.

12:07:43.188 | INFO    | prefect.infrastructure.docker-container - Pulling image '0d191eb865749afb42ebdfd700a2a975c1f20b95'...
Traceback (most recent call last):
  File "/home/usr/anaconda3/envs/sandbox/lib/python3.10/site-packages/docker/api/", line 268, in _raise_for_status
  File "/home/usr/anaconda3/envs/sandbox/lib/python3.10/site-packages/requests/", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.41/images/create?tag=latest&fromImage=0d191eb865749afb42ebdfd700a2a975c1f20b95

Any help would be appreciated

1 Like

Nevermind, problem was the image had to be the full url, not the image_tag

So working code was to have

image_tag = ""
1 Like

thanks so much for sharing your solution :raised_hands: great to see you figure that out so quickly

1 Like