https://prefect.io logo
Title
p

Prasanth Kothuri

10/27/2021, 4:59 PM
I am running my flows in DockerAgent, the image I want to use is in private gitlab registry, how can I specify username and token required to pull the image ?
a

Anna Geller

10/27/2021, 5:11 PM
@Prasanth Kothuri you could try passing it as environment variables either on: #1 Run configuration
flow.run_config = DockerRun(
    env={"SOME_VAR": "VALUE"},
    image="example/image-name:with-tag"
)
#2 or on the agent
prefect agent docker start --env KEY=value
probably #2 is better because the agent is pulling the image when deploying a flow, afaik
k

Kevin Kho

10/27/2021, 5:14 PM
I think you need the second one here
p

Prasanth Kothuri

10/27/2021, 5:18 PM
ok, what would be the name of these environment variables ? when I pull manually I do
docker login
and then do
docker pull
k

Kevin Kho

10/27/2021, 5:19 PM
Let me try checking their CLI
Looks like you need to authenticate your agent like this
before_script:
  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
As per
<https://docs.gitlab.com/ee/user/packages/container_registry/>
So that it can just
docker pull
p

Prasanth Kothuri

10/27/2021, 5:37 PM
sure, but who does the docker login ?
k

Kevin Kho

10/27/2021, 5:41 PM
You do on the agent machine before you spin the agent because the agent just uses the underlying
docker pull
. So you would authenticate the agent.
p

Prasanth Kothuri

10/27/2021, 5:43 PM
yes thats what I am doing now, i thought the prefect docker agent has some option to do this.. looks like there is not
k

Kevin Kho

10/27/2021, 5:56 PM
Been looking and yeah I guess Gitlab doesn’t have a way to authenticate with environment variables. That was the initial suggestion cuz AWS and GCP provide such ways