Skip to content

ChiragAgg5k/docker-use

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-use banner

docker-use

Manage multiple Docker Hub accounts from the command line.

Why

Docker only reads credentials from the active DOCKER_CONFIG, which makes switching between personal, work, and automation accounts awkward. You either keep logging in and out, manually juggle config directories, or risk pushing and pulling with the wrong account.

docker-use keeps each account in its own isolated Docker config and lets your shell switch between them by name.

Install

brew tap chiragagg5k/tools
brew install docker-use

Or download a binary from the releases page.

Setup

Add the following to your shell rc file (e.g., ~/.zshrc):

eval "$(docker-use init zsh)"

The generated wrapper calls docker-use <name> and assigns the returned path to DOCKER_CONFIG without shell eval during account switching.

Supported shells: zsh, bash, fish.

Usage

docker-use list                  # list accounts
docker-use whoami                # show current account
docker-use add <name> -u <user>  # add a new account (interactive docker login)
docker-use add <name> -u <user> --force  # replace an existing account
docker-use remove <name>         # remove an account (with confirmation)
docker-use <name>                # switch to an account (requires shell wrapper)

How it works

Each account lives in ~/.docker-accounts/<name>/config.json. Account names must match ^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$. When you use an account, the shell wrapper sets DOCKER_CONFIG to that directory, so docker commands use the right credentials.

During add, docker-use shells out to docker login, then preserves Docker's generated credential helper settings such as credsStore: osxkeychain so Docker Desktop and platform keychains keep working inside the selected account config.

About

CLI to manage multiple Docker Hub accounts

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors