Skip to content

Share CLI credentials over a unix socket - #5948

Draft
Benehiko wants to merge 1 commit into
docker:masterfrom
Benehiko:credential-server
Draft

Share CLI credentials over a unix socket#5948
Benehiko wants to merge 1 commit into
docker:masterfrom
Benehiko:credential-server

Conversation

@Benehiko

@BenehikoBenehiko commented Mar 21, 2025

Copy link
Copy Markdown
Member

This PR is a proof of concept to share docker credentials from the CLI.
Related to #5858

What is the benefit of this?

  • Keep the credentials in sync (OAuth credentials refresh - currently in CLI they do not, but DD does)
  • Single source of truth
  • No need to worry about if the credentials are stored in the config or inside the credential helper, the CLI already has mechanisms to detect it for you.
./build/docker-darwin-arm64 auth credential-serverStarting credential server...
curl http://localhost/credentials --unix-socket ~/.docker/run/docker_cli_credential_server.sock

- What I did
Created a command called auth which is a manager for the CLI credentials. This allows us to expose the credentials that the CLI have access to (config, credential helper etc.).

docker auth credential-server

This will create a new unix socket inside the default docker config directory ~/.docker/run/docker_cli_credential_server.sock. Using this socket you can retrieve the credentials, save credentials back and delete credentials.

The CLI has a built in mechanism that would detect the docker_cli_credential_server.sock and implements the credentials.Store interface so that any calls to the socket would correctly return types.AuthConfig as normal. This means that the socket iteslf becomes a credential store.

This also solves situatations where the docker CLI need credentials when run inside of a docker container.

docker buildx bake --set binary.platform=linux/arm64docker run -it -v ./build/docker-linux-arm64:/bin/docker -v /Users/benehiko/.docker/run/docker_cli_credential_server.sock:/root/.docker/run/docker_cli_credential_server.sock -v /var/run/docker.sock:/var/run/docker.sock alpine:latest /bin/ash/ # docker loginAuthenticating with existing credentials... [Username: <your username>]i Info → To login with a different account, run 'docker logout' followed by 'docker login'Login Succeeded

- How I did it

- How to verify it

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

@codecov-commenter

codecov-commenter commented Mar 21, 2025

Copy link
Copy Markdown

Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
@BenehikoBenehiko mentioned this pull request Mar 21, 2025
4 tasks
D3-LucaPiombino added a commit to CodeCoil/container-desktop that referenced this pull request Jun 2, 2025
…uildx: `0.24.0`) (#10)
## Summary of the Pull Request
Update docker (and related tooling) to the latest version.
## Detailed Description of the Pull Request / Additional comments
The core motivation is to have a version of the docker client that does
not attempt to mutate/rewrite the config
(docker/cli#5553).
This is in preparation of a future enhancement to share the same client
configuration of the windows host and to provide a seamless experience.
This could include also the auth via credential helpers running on the
host (e.g. a basic scenario is to at least use the windows credential
manager to avoid storing static credentials in plain in the config
file).
I did not push anything yet because i am waiting to see if
docker/cli#5948
get merged as it would probably provide a better and simpler out of the box experience.
Co-authored-by: Luca Piombino <luca.piombino@codecoil.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Benehiko@codecov-commenter