docker / docker/docker-py

Legacy config file format

Open
#1,930 3 comments 0 reactions 1 assignee View on GitHub

@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:

  1. Docker itself is fully backwards compatible and CAN read from ~/.dockercfg, but will always write new data to ~/.docker/config.json
  2. Gcloud will write to ~/.dockercfg using the old file format (plain config object) IF there is no ~/.docker/config.json. ELSE it will write to ~/.docker/config.json using the new file format (auths object inside config object).
  3. docker-py will read from either ~/.dockercfg or ~/.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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.