Search code examples
pythonmacosdockerdockerpy

Get docker preferences using docker-py


I am trying to read the configs (preferences) set manually using docker preferences on mac from docker-py python module.

I see that these preferences are stored in ~/.docker/config.json but I don't seem to find a way to access them using docker client.

I am trying to access the preference, "Securely store Docker logins in macOS keychain" particularly.

I see that we can set the config file using

docker --config

but, there is no getter for this config file?

I can see 'credsStore' property in the docker config.json but, when I try client.configs I get an empty list.

import docker
client = docker.from_env()
client.configs.list()

I would expect to see the value of that particular config.


Solution

  • You can't access client configuration information (~/docker/config.json) via the Docker API. The information in that file effects the behavior of the client but it is not part of the API.

    The configs method in the API is for accessing container configuration data in Docker Swarm (see "Store configuration data using Docker Configs").

    You can find the complete Docker API reference here.