Fina Silva-Santisteban
02/22/2021, 10:52 PMaws ecr get-login-password --region regionname | docker login --username AWS --password-stdin <http://xxxxxx.dkr.ecr.us-east-2.amazonaws.com|xxxxxx.dkr.ecr.us-east-2.amazonaws.com>
. I’ve tried using boto3 to do a docker login right before the register()
call but it seems like the auth token expires as soon as I run register:
denied: Your authorization token has expired. Reauthenticate and try again.
Is it possible to have Prefect do the docker login? Or do I always have to use the AWS CLI?Zanie
Fina Silva-Santisteban
02/22/2021, 11:06 PMdef connect_docker_client_to_cloud():
(some boto3 setup)
(...)
login_result = dockerClient.login(username=username, password=password, registry=registry)
print(login_result) # Returns {'IdentityToken': '', 'Status': 'Login Succeeded'}
def register_flows
(some prefect setup)
(...)
connect_docker_client_to_cloud()
flow.register(project_name=project_name) #Returns denied: Your authorization token has expired.
Zanie
Zanie
dockerClient.login
is not?Fina Silva-Santisteban
02/22/2021, 11:11 PMlogin succeeded
as well. 🤔Zanie
reauth (bool): Whether or not to refresh existing authentication on
the Docker server.
Zanie
Zanie
flow.register
it is creating a new instance of the docker client that does not have your authentication attachedZanie
Docker(Storage)
class
def _get_client(self) -> "docker.APIClient":
# 'import docker' is expensive time-wise, we should do this just-in-time to keep
# the 'import prefect' time low
import docker
client = docker.APIClient(
base_url=self.base_url, version="auto", tls=self.tls_config
)
client.login()
Zanie
Docker
storage and overriding this function to call login
with your args -- I'm not sure that'll work with serialization and such though. I'll send a message to the rest of the team asking about this pattern.Fina Silva-Santisteban
02/22/2021, 11:27 PMZanie
docker login ...
in a subprocess/shell from python. I believe it's just writing auth information to a file which is then pulled if you call client.login()
without args.Fina Silva-Santisteban
02/23/2021, 1:08 AMreauth
didn’t change anything either! I’ve also tried a few different to do the docker login according to what I found on stackoverflow, but no luck either. I guess I’ll have to go with the aws cli docker login for now. 😓 In case anybody else stumbles upon this, the command is this one:
aws ecr get-login-password --region yourregion | docker login --username AWS --password-stdin <http://yourregistryid.dkr.ecr.yourregion.amazonaws.com|yourregistryid.dkr.ecr.yourregion.amazonaws.com>