Harbor CLI β a command-line interface for interacting with your Harbor container registry. A streamlined, user-friendly alternative to the WebUI, as your daily driver or for scripting and automation.
- CLI alternative to the WebUI
- Tool for scripting and automation of common repeatable Harbor tasks running on your machine or inside your pipeline
The project's first goal is to reach WebUI parity.
β
project Mange projects
β
repo Manage repositories
β
artifact Manage artifacts
β
label Manage labels
β
tag Manage tags
β
quota Manage quotas
β
webhook Manage webhook policies
β robot Robot Account
β
login Log in to Harbor registry
β
user Manage users
β
registry Manage registries
β replication Manage replication
β
config Manage the config of the Harbor CLI
β
cve-allowlist Manage system CVE allowlist
β
health Get the health status of Harbor components
β
instance Manage preheat provider instances in Harbor
β
info Display detailed Harbor system, statistics, and CLI environment information
β
scanner scanner commands
β
schedule Schedule jobs in Harbor
β
completion Generate the autocompletion script for the specified shell\
β
help Help about any command
β
version Version of Harbor CLI
Running Harbor CLI as a container is simple. Use the following command to get started:
docker run -ti --rm -v $HOME/.config/harbor-cli/config.yaml:/root/.config/harbor-cli/config.yaml \
-e HARBOR_ENCRYPTION_KEY=$(echo "ThisIsAVeryLongPassword" | base64) \
registry.goharbor.io/harbor-cli/harbor-cli \
--help
Use the HARBOR_ENCRYPTION_KEY
container environment variable as a base64-encoded 32-byte key for AES-256 encryption. This securely stores your harbor login password.
I you intend to run the CLI as a container,it is advised to set the following environment variables and to create an alias and append the alias to your .zshrc or .bashrc file
echo "export HARBOR_CLI_CONFIG=\$HOME/.config/harbor-cli/config.yaml" >> ~/.zshrc
echo "export HARBOR_ENCRYPTION_KEY=\$(cat <path_to_32bit_private_key_file> | base64)" >> ~/.zshrc
echo "alias harbor='docker run -ti --rm -v \$HARBOR_CLI_CONFIG:/root/.config/harbor-cli/config.yaml -e HARBOR_ENCRYPTION_KEY=\$HARBOR_ENCRYPTION_KEY registry.goharbor.io/harbor-cli/harbor-cli'" >> ~/.zshrc
source ~/.zshrc # or restart your terminal
Harbor CLI will soon be published on Homebrew. Meantime, we recommend using Harbor in the Container or downloading the binary from the releases page
Using Curl or Wget isn't needed if you want to add the Harbor CLI to your container. Instead, we recommend copying the Harbor CLI from our official image by using the following Dockerfile:
#...
COPY --from=registry.goharbor.io/harbor-cli/harbor-cli:latest /harbor /usr/local/bin/harbor
# --chown and --chmod flags can be used to set the permissions
>./harbor
Official Harbor CLI
Usage:
harbor [command]
Examples:
// Base command:
harbor
// Display help about the command:
harbor help
Available Commands:
artifact Manage artifacts
completion Generate the autocompletion script for the specified shell
config Manage the config of the Harbor CLI
cve-allowlist Manage system CVE allowlist
health Get the health status of Harbor components
help Help about any command
info Show the current credential information
instance Manage preheat provider instances in Harbor
label Manage labels in Harbor
login Log in to Harbor registry
project Manage projects and assign resources to them
registry Manage registries
repo Manage repositories
schedule Schedule jobs in Harbor
tag Manage tags in Harbor registry
user Manage users
version Version of Harbor CLI
Flags:
-c, --config string config file (default is $HOME/.config/harbor-cli/config.yaml)
-h, --help help for harbor
-o, --output-format string Output format. One of: json|yaml
-v, --verbose verbose output
Use "harbor [command] --help" for more information about a command.
Use the --config
flag to specify a custom configuration file path (the highest priority).
harbor --config /path/to/custom/config.yaml artifact list
If --config
is not provided, Harbor CLI checks the HARBOR_CLI_CONFIG
environment variable for the config file path.
export HARBOR_CLI_CONFIG=/path/to/custom/config.yaml
harbor artifact list
If neither is set, it defaults to $XDG_CONFIG_HOME/harbor-cli/config.yaml
or $HOME/.config/harbor-cli/config.yaml
if XDG_CONFIG_HOME
is unset.
harbor artifact list
- Data paths are determined by the
XDG_DATA_HOME
environment variable. - If
XDG_DATA_HOME
is not set, it defaults to$HOME/.local/share/harbor-cli/data.yaml
. - The data file always contains the path of the latest config used.
--config
flag >HARBOR_CLI_CONFIG
environment variable > default XDG config paths.- Environment variables override default settings, and the
--config
flag takes precedence over both environment variables and defaults. - The data file always contains the path of the latest config used.
harbor login demo.goharbor.io -u harbor-cli -p Harbor12345
harbor project create
harbor project list
# output
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Project Name Access Level Type Repo Count Creation Time β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β library public project 0 1 hour ago β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
harbor repo list
# output
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Name Artifacts Pulls Last Modified Time β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β library/harbor-cli 1 0 0 minute ago β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Platform | Status |
---|---|
Linux | β |
macOS | β |
Windows | β |
Make sure you have the latest Dagger installed in your system.
git clone https://github.com/goharbor/harbor-cli.git && cd harbor-cli
dagger call build-dev --platform darwin/arm64 export --path=./harbor-cli
./harbor-dev --help
If golang is installed in your system, you can also build the project using the following commands:
git clone https://github.com/goharbor/harbor-cli.git && cd harbor-cli
go build -o harbor-cli cmd/harbor/main.go
At the moment, the Harbor CLI is developed and tested with Harbor 2.13. The CLI should work with versions prior to 2.13, but not all functionalities may be available or work as expected.
Harbor <2.0.0 is not supported.
- Twitter: @project_harbor
- User Group: Join Harbor user email group: [email protected] to get update of Harbor's news, features, releases, or to provide suggestion and feedback.
- Developer Group: Join Harbor developer group: [email protected] for discussion on Harbor development and contribution.
- Slack: Join Harbor's community for discussion and ask questions: Cloud Native Computing Foundation, channel: #harbor, #harbor-dev and #harbor-cli.
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.
This project is maintained by the Harbor community. We thank all our contributors and users for their support.
For any questions or issues, please open an issue on our GitHub Issues page.
Give a β if this project helped you, Thank YOU!