https://prefect.io logo
Title
a

Adam Roderick

05/28/2020, 4:51 AM
Hi, I'm trying to work through flow registration with cloud using Docker storage
I keep getting an exception from docker.py line 544
push_image
that says "no basic auth credentials"
So I created some code using the python docker library to log into the registry. That succeeds, and the next thing I do is call
flow.register()
. Same error
So this may be more of a docker question, but any thoughts on how to get past this issue?
c

Chris White

05/28/2020, 4:58 AM
Hey @Adam Roderick - I recommend working on this with Docker directly instead of through Prefect’s
.register()
call; I suggest starting by trying to pull your
base_image
or push to your configured
registry_url
and seeing if that raises the same error
a

Adam Roderick

05/28/2020, 5:03 AM
Thanks, @Chris White. I'll try that
ūüĎć 1
a

Arsenii

05/28/2020, 5:34 AM
Hey @Adam Roderick, I think I had a similar error message at first when trying to register DockerStorage with a private ECR. Double-check the Docker-related configurations that you pass to the Storage object, especially stuff like
base_url
-- the defaults may not be optimal. For me in the end, it turned out I had to pass
tls_config
since the running Docker was configured with that level of security. Otherwise the authentication failed
a

Adam Roderick

05/28/2020, 5:36 AM
Thanks @Arsenii. By walking through the steps using the docker CLI, I was able to get past the issue
One thing I have to do is call
boto3.client('ecr').create_repository()
to ensure it exists before trying to push to it. That was the only additional thing I ran into
I believe that python docker.login is not saving credentials. If I log in through docker CLI, the creds are saved to ~/.docker/config.json
Not so if I do the login through python
docker.login()
Was an issue in the past; could still be today https://github.com/docker/docker-py/issues/1061
a

Arsenii

05/28/2020, 5:39 AM
One thing I have to do is call 
boto3.client('ecr').create_repository()
Ah, interesting. I'm basically reusing the same repository but assign unique tags to each flow's docker image -- so no need to create new repos all the time
a

Adam Roderick

05/28/2020, 5:43 AM
That's a good idea. In our use case, we need many repos
So what is the right way to login via docker before calling
flow.register()
? If I don't login at all, I get the "no basic auth credentials" error.
If I manually log in via the command line, then the creds are saved
But manually logging in doesn't seem like the best way to go
I ended up with this
subprocess.run(['docker', 'login', '-u', username, '-p', password, url])
ūü§®
ūüßź 1