I am running my flows in DockerAgent, the image I ...
# prefect-server
p
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
@Prasanth Kothuri you could try passing it as environment variables either on: #1 Run configuration
Copy code
flow.run_config = DockerRun(
    env={"SOME_VAR": "VALUE"},
    image="example/image-name:with-tag"
)
#2 or on the agent
Copy code
prefect agent docker start --env KEY=value
probably #2 is better because the agent is pulling the image when deploying a flow, afaik
k
I think you need the second one here
p
ok, what would be the name of these environment variables ? when I pull manually I do
docker login
and then do
docker pull
k
Let me try checking their CLI
Looks like you need to authenticate your agent like this
Copy code
before_script:
  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
As per
Copy code
<https://docs.gitlab.com/ee/user/packages/container_registry/>
So that it can just
docker pull
p
sure, but who does the docker login ?
k
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
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
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