36

When I do a docker login to a private repository using docker 1.10.1, an entry is created in my ~/.docker/config.json file. Is this file in the same format as what I see being called a .dockercfg file? Is the config.json file interchangeable with a .dockercfg file?

1 Answer 1

39

I assume config.json is the new .dockercfg file.
See "docker/cliconfig/config.go"

// ConfigFileName is the name of config file
ConfigFileName = "config.json"
oldConfigfile  = ".dockercfg"

The new config file is now documented under man/config-json.5.md

That was introduced in commit 18c9b6c in docker 1.7.0 (April 2015)

Add .docker/config.json and support for HTTP Headers

This PR does the following:

  • migrated ~/.dockerfg to ~/.docker/config.json.
    The data is migrated but the old file remains in case its needed.

Note: since 2016:

It differs from docker-daemon.8.md which uses by default /etc/docker/daemon.json, the daemon configuration file introduced with Docker v1.10.

So:

But the config.json (which applies to all containers) does not include docker run network settings: --net=host could not be specified in that config file.


Update 2021 (since 2017), as noted by slm in the comments:

The credentials are now stored in whatever your OS makes use of for managing secrets.
On MacOS they get stored under Keychain, you can find them by looking for "Docker Credentials" under All Items

You can see the project docker/docker-credential-helpers: a suite of programs to use native stores to keep Docker credentials safe.

See docker login/Credentials Store for more.

5
  • 1
    What is the relationship between ./docker/config.json and /etc/docker/daemon.json? i know i can add proxy in config.json. But if i want to add "--net=host" to a config file, what should i do? May 20, 2020 at 8:16
  • @Justalittlenoob I have edited the answer to address your comment/question.
    – VonC
    May 20, 2020 at 11:30
  • Great, very detailed. Thanks:) May 26, 2020 at 10:33
  • BTW, the credentials are now stored in whatever your OS makes use of for managing secrets. On MacOS they get stored under Keychain, you can find them by looking for "Docker Credentials" under All Items.
    – slm
    Apr 8, 2021 at 21:16
  • @slm Good point, thank you. I have included your comment in the answer for more visibility
    – VonC
    Apr 8, 2021 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.