Legacy config file format
@shin- is already working on this.
Since Mar 13, 2018.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
Hey there,
I recently noticed a bad/wrong behaviour of this library when using docker-compose pull.
docker-compose.yml:
version: '2'
services:
test:
image: eu.gcr.io/some/private/image:latest
If I authenticate myself using gcloud docker login && gcloud docker -a, I cannot pull the image with docker-compose. When I log in with docker login -u _token -p $(gcloud auth print-access-token) eu.gcr.io, it works.
Furthermore, I can pull the exact same image doing docker pull eu.gcr.io/some/private/image:latest after logging in with gcloud docker login && gcloud docker -a. (This is why I post here instead of creating an issue in google-cloud-sdk)
I looked at the source code of docker, gcloud and docker-py and found out the following:
- Docker itself is fully backwards compatible and CAN read from
~/.dockercfg, but will always write new data to~/.docker/config.json - Gcloud will write to
~/.dockercfgusing the old file format (plain config object) IF there is no~/.docker/config.json. ELSE it will write to~/.docker/config.jsonusing the new file format (authsobject inside config object). - docker-py will read from either
~/.dockercfgor~/.docker/config.json, but only uses the new format (see: https://github.com/docker/docker-py/blob/master/docker/auth.py#L104)
So, if there is no ~/.docker/config.json and one does gcloud docker login && gcloud docker -a, ~/.dockercfg is created in the old format, which docker-py won't read. Thus, it cannot find the auth credentials and docker-compose pull fails.
IMO, docker-py should use the old format for the old file and the new format for the new file, as both docker and Gcloud do.
I worked around this by using docker login -u _token -p $(gcloud auth print-access-token) eu.gcr.io for now, but others might run into the same problem.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.