summaryrefslogtreecommitdiff
path: root/plugins/docker
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2023-01-17 12:46:15 +0100
committerTuowen Zhao <ztuowen@gmail.com>2023-01-17 12:46:15 +0100
commitdb7efd2336e4dbe6abf321b00dbc11bc5afb1355 (patch)
tree720a58ff82bf0a0e0167594131f872d453b1828e /plugins/docker
parent04b8c052e5b624873b352889423c753ed1baf9c4 (diff)
parent8f0e296dbf27026ea0515ebae0d3cc41f236ecdc (diff)
downloadzsh-db7efd2336e4dbe6abf321b00dbc11bc5afb1355.tar.gz
zsh-db7efd2336e4dbe6abf321b00dbc11bc5afb1355.tar.bz2
zsh-db7efd2336e4dbe6abf321b00dbc11bc5afb1355.zip
Merge remote-tracking branch 'github/master'
Diffstat (limited to 'plugins/docker')
-rw-r--r--plugins/docker/README.md88
-rw-r--r--plugins/docker/_docker54
-rw-r--r--plugins/docker/docker.plugin.zsh34
3 files changed, 73 insertions, 103 deletions
diff --git a/plugins/docker/README.md b/plugins/docker/README.md
index 606690f14..512b5d17c 100644
--- a/plugins/docker/README.md
+++ b/plugins/docker/README.md
@@ -13,18 +13,15 @@ https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker
## Settings
-By default, the completion doesn't allow option-stacking, meaning if you try to
-complete `docker run -it <TAB>` it won't work, because you're _stacking_ the
-`-i` and `-t` options.
+By default, the completion doesn't allow option-stacking, meaning if you try to complete
+`docker run -it <TAB>` it won't work, because you're _stacking_ the `-i` and `-t` options.
-[You can enable it](https://github.com/docker/cli/commit/b10fb43048) by **adding
-the lines below to your zshrc file**, but be aware of the side effects:
+[You can enable it](https://github.com/docker/cli/commit/b10fb43048) by **adding the lines below to your zshrc
+file**, but be aware of the side effects:
-> This enables Zsh to understand commands like `docker run -it
-> ubuntu`. However, by enabling this, this also makes Zsh complete
-> `docker run -u<tab>` with `docker run -uapprox` which is not valid. The
-> users have to put the space or the equal sign themselves before trying
-> to complete.
+> This enables Zsh to understand commands like `docker run -it ubuntu`. However, by enabling this, this also
+> makes Zsh complete `docker run -u<tab>` with `docker run -uapprox` which is not valid. The users have to put
+> the space or the equal sign themselves before trying to complete.
>
> Therefore, this behavior is disabled by default. To enable it:
>
@@ -35,39 +32,38 @@ the lines below to your zshrc file**, but be aware of the side effects:
## Aliases
-| Alias | Command | Description |
-| :------ | :-------------------------- | :--------------------------------------------------------------------------------------- |
-| dbl | `docker build` | Build an image from a Dockerfile |
-| dcin | `docker container inspect` | Display detailed information on one or more containers |
-| dlo | `docker container logs` | Fetch the logs of a docker container |
-| dcls | `docker container ls` | List all the running docker containers |
-| dclsa | `docker container ls -a` | List all running and stopped containers |
-| dpo | `docker container port` | List port mappings or a specific mapping for the container |
-| dpu | `docker pull` | Pull an image or a repository from a registry |
-| dr | `docker container run` | Create a new container and start it using the specified command |
-| drit | `docker container run -it` | Create a new container and start it in an interactive shell |
-| drm | `docker container rm` | Remove the specified container(s) |
-| drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) |
-| dst | `docker container start` | Start one or more stopped containers |
-| dstp | `docker container stop` | Stop one or more running containers |
-| dtop | `docker top` | Display the running processes of a container |
-| dxc | `docker container exec` | Run a new command in a running container |
-| dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell |
-| | | **Docker Images** |
-| dib | `docker image build` | Build an image from a Dockerfile (same as docker build) |
-| dii | `docker image inspect` | Display detailed information on one or more images |
-| dils | `docker image ls` | List docker images |
-| dipu | `docker image push` | Push an image or repository to a remote registry |
-| dirm | `docker image rm` | Remove one or more images |
-| dit | `docker image tag` | Add a name and tag to a particular image |
-| | | **Docker Network** |
-| dnc | `docker network create` | Create a new network |
-| dncn | `docker network connect` | Connect a container to a network |
-| dndcn | `docker network disconnect` | Disconnect a container from a network |
-| dni | `docker network inspect` | Return information about one or more networks |
-| dnls | `docker network ls` | List all networks the engine daemon knows about, including those spanning multiple hosts |
-| dnrm | `docker network rm` | Remove one or more networks |
-| | | **Docker Volume** |
-| dvi | `docker volume inspect` | Display detailed information about one or more volumes |
-| dvls | `docker volume ls` | List all the volumes known to docker |
-| dvprune | `docker volume prune` | Cleanup dangling volumes |
+| Alias | Command | Description |
+| :------ | :---------------------------- | :--------------------------------------------------------------------------------------- |
+| dbl | `docker build` | Build an image from a Dockerfile |
+| dcin | `docker container inspect` | Display detailed information on one or more containers |
+| dcls | `docker container ls` | List all the running docker containers |
+| dclsa | `docker container ls -a` | List all running and stopped containers |
+| dib | `docker image build` | Build an image from a Dockerfile (same as docker build) |
+| dii | `docker image inspect` | Display detailed information on one or more images |
+| dils | `docker image ls` | List docker images |
+| dipu | `docker image push` | Push an image or repository to a remote registry |
+| dirm | `docker image rm` | Remove one or more images |
+| dit | `docker image tag` | Add a name and tag to a particular image |
+| dlo | `docker container logs` | Fetch the logs of a docker container |
+| dnc | `docker network create` | Create a new network |
+| dncn | `docker network connect` | Connect a container to a network |
+| dndcn | `docker network disconnect` | Disconnect a container from a network |
+| dni | `docker network inspect` | Return information about one or more networks |
+| dnls | `docker network ls` | List all networks the engine daemon knows about, including those spanning multiple hosts |
+| dnrm | `docker network rm` | Remove one or more networks |
+| dpo | `docker container port` | List port mappings or a specific mapping for the container |
+| dpu | `docker pull` | Pull an image or a repository from a registry |
+| dr | `docker container run` | Create a new container and start it using the specified command |
+| drit | `docker container run -it` | Create a new container and start it in an interactive shell |
+| drm | `docker container rm` | Remove the specified container(s) |
+| drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) |
+| dst | `docker container start` | Start one or more stopped containers |
+| drs | `docker container restart` | Restart one or more containers
+| dsta | `docker stop $(docker ps -q)` | Stop all running containers |
+| dstp | `docker container stop` | Stop one or more running containers |
+| dtop | `docker top` | Display the running processes of a container |
+| dvi | `docker volume inspect` | Display detailed information about one or more volumes |
+| dvls | `docker volume ls` | List all the volumes known to docker |
+| dvprune | `docker volume prune` | Cleanup dangling volumes |
+| dxc | `docker container exec` | Run a new command in a running container |
+| dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell |
diff --git a/plugins/docker/_docker b/plugins/docker/_docker
index 8ee35abcf..e6a12d774 100644
--- a/plugins/docker/_docker
+++ b/plugins/docker/_docker
@@ -567,7 +567,7 @@ __docker_container_commands() {
"cp:Copy files/folders between a container and the local filesystem"
"create:Create a new container"
"diff:Inspect changes on a container's filesystem"
- "exec:Run a command in a running container"
+ "exec:Execute a command in a running container"
"export:Export a container's filesystem as a tar archive"
"inspect:Display detailed information on one or more containers"
"kill:Kill one or more running containers"
@@ -579,7 +579,7 @@ __docker_container_commands() {
"rename:Rename a container"
"restart:Restart one or more containers"
"rm:Remove one or more containers"
- "run:Run a command in a new container"
+ "run:Create and run a new container from an image"
"start:Start one or more stopped containers"
"stats:Display a live stream of container(s) resource usage statistics"
"stop:Stop one or more running containers"
@@ -650,6 +650,7 @@ __docker_container_subcommand() {
"($help)*"{-p=,--publish=}"[Expose a container's port to the host]:port:_ports"
"($help)--pid=[PID namespace to use]:PID namespace:__docker_complete_pid"
"($help)--privileged[Give extended privileges to this container]"
+ "($help -q --quiet)"{-q,--quiet}"[Suppress the pull output]"
"($help)--read-only[Mount the container's root filesystem as read only]"
"($help)*--security-opt=[Security options]:security option: "
"($help)*--shm-size=[Size of '/dev/shm' (format is '<number><unit>')]:shm size: "
@@ -802,7 +803,7 @@ __docker_container_subcommand() {
"($help -a --all)"{-a,--all}"[Show all containers]" \
"($help)--before=[Show only container created before...]:containers:__docker_complete_containers" \
"($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_ps_filters" \
- "($help)--format=[Pretty-print containers using a Go template]:template: " \
+ "($help)--format=[Format the output using the given Go template]:template: " \
"($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \
"($help -n --last)"{-n=,--last=}"[Show n last created containers (includes all states)]:n:(1 5 10 25 50)" \
"($help)--no-trunc[Do not truncate output]" \
@@ -907,7 +908,7 @@ __docker_container_subcommand() {
_arguments $(__docker_arguments) \
$opts_help \
"($help -a --all)"{-a,--all}"[Show all containers (default shows just running)]" \
- "($help)--format=[Pretty-print images using a Go template]:template: " \
+ "($help)--format=[Format the output using the given Go template]:template: " \
"($help)--no-stream[Disable streaming stats and only pull the first result]" \
"($help)--no-trunc[Do not truncate output]" \
"($help -)*:containers:__docker_complete_running_containers" && ret=0
@@ -973,8 +974,8 @@ __docker_image_commands() {
"load:Load an image from a tar archive or STDIN"
"ls:List images"
"prune:Remove unused images"
- "pull:Pull an image or a repository from a registry"
- "push:Push an image or a repository to a registry"
+ "pull:Download an image from a registry"
+ "push:Upload an image to a registry"
"rm:Remove one or more images"
"save:Save one or more images to a tar archive (streamed to STDOUT by default)"
"tag:Tag an image into a repository"
@@ -1060,7 +1061,7 @@ __docker_image_subcommand() {
"($help -a --all)"{-a,--all}"[Show all images]" \
"($help)--digests[Show digests]" \
"($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_images_filters" \
- "($help)--format=[Pretty-print images using a Go template]:template: " \
+ "($help)--format=[Format the output using the given Go template]:template: " \
"($help)--no-trunc[Do not truncate output]" \
"($help -q --quiet)"{-q,--quiet}"[Only show image IDs]" \
"($help -): :__docker_complete_repositories" && ret=0
@@ -1082,7 +1083,7 @@ __docker_image_subcommand() {
(push)
_arguments $(__docker_arguments) \
$opts_help \
- "($help -a --all-tags)"{-a,--all-tags}"[Push all tagged images in the repository]" \
+ "($help -a --all-tags)"{-a,--all-tags}"[Push all tags of an image to the repository]" \
"($help)--disable-content-trust[Skip image signing]" \
"($help -): :__docker_complete_images" && ret=0
;;
@@ -1292,7 +1293,7 @@ __docker_network_subcommand() {
$opts_help \
"($help)--no-trunc[Do not truncate the output]" \
"($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_network_complete_ls_filters" \
- "($help)--format=[Pretty-print networks using a Go template]:template: " \
+ "($help)--format=[Format the output using the given Go template]:template: " \
"($help -q --quiet)"{-q,--quiet}"[Only display network IDs]" && ret=0
;;
(prune)
@@ -2050,7 +2051,7 @@ __docker_service_subcommand() {
_arguments $(__docker_arguments) \
$opts_help \
"($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_service_complete_ls_filters" \
- "($help)--format=[Pretty-print services using a Go template]:template: " \
+ "($help)--format=[Format the output using the given Go template]:template: " \
"($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0
;;
(rm|remove)
@@ -2253,7 +2254,7 @@ __docker_stack_subcommand() {
_arguments $(__docker_arguments) \
$opts_help \
"($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_stack_complete_services_filters" \
- "($help)--format=[Pretty-print services using a Go template]:template: " \
+ "($help)--format=[Format the output using the given Go template]:template: " \
"($help -q --quiet)"{-q,--quiet}"[Only display IDs]" \
"($help -):stack:__docker_complete_stacks" && ret=0
;;
@@ -2520,7 +2521,7 @@ __docker_volume_subcommand() {
_arguments $(__docker_arguments) \
$opts_help \
"($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_volume_complete_ls_filters" \
- "($help)--format=[Pretty-print volumes using a Go template]:template: " \
+ "($help)--format=[Format the output using the given Go template]:template: " \
"($help -q --quiet)"{-q,--quiet}"[Only display volume names]" && ret=0
;;
(prune)
@@ -2582,10 +2583,8 @@ __docker_context_subcommand() {
(create)
_arguments $(__docker_arguments) \
$opts_help \
- "($help)--default-stack-orchestrator=[Default orchestrator for stack operations to use with this context]:default-stack-orchestrator:(swarm kubernetes all)" \
"($help)--description=[Description of the context]:description:" \
"($help)--docker=[Set the docker endpoint]:docker:" \
- "($help)--kubernetes=[Set the kubernetes endpoint]:kubernetes:" \
"($help)--from=[Create context from a named context]:from:__docker_complete_contexts" \
"($help -):name: " && ret=0
;;
@@ -2607,10 +2606,8 @@ __docker_context_subcommand() {
(update)
_arguments $(__docker_arguments) \
$opts_help \
- "($help)--default-stack-orchestrator=[Default orchestrator for stack operations to use with this context]:default-stack-orchestrator:(swarm kubernetes all)" \
"($help)--description=[Description of the context]:description:" \
"($help)--docker=[Set the docker endpoint]:docker:" \
- "($help)--kubernetes=[Set the kubernetes endpoint]:kubernetes:" \
"($help -):name:" && ret=0
;;
esac
@@ -2734,9 +2731,6 @@ __docker_subcommand() {
"($help -b --bridge)"{-b=,--bridge=}"[Attach containers to a network bridge]:bridge:_net_interfaces" \
"($help)--bip=[Network bridge IP]:IP address: " \
"($help)--cgroup-parent=[Parent cgroup for all containers]:cgroup: " \
- "($help)--cluster-advertise=[Address or interface name to advertise]:Instance to advertise (host\:port): " \
- "($help)--cluster-store=[URL of the distributed storage backend]:Cluster Store:->cluster-store" \
- "($help)*--cluster-store-opt=[Cluster store options]:Cluster options:->cluster-store-options" \
"($help)--config-file=[Path to daemon configuration file]:Config File:_files" \
"($help)--containerd=[Path to containerd socket]:socket:_files -g \"*.sock\"" \
"($help)--containerd-namespace=[Containerd namespace to use]:containerd namespace:" \
@@ -2778,7 +2772,7 @@ __docker_subcommand() {
"($help)--oom-score-adjust=[Set the oom_score_adj for the daemon]:oom-score:(-500)" \
"($help -p --pidfile)"{-p=,--pidfile=}"[Path to use for daemon PID file]:PID file:_files" \
"($help)--raw-logs[Full timestamps without ANSI coloring]" \
- "($help)*--registry-mirror=[Preferred Docker registry mirror]:registry mirror: " \
+ "($help)*--registry-mirror=[Preferred registry mirror]:registry mirror: " \
"($help)--seccomp-profile=[Path to seccomp profile]:path:_files -g \"*.json\"" \
"($help -s --storage-driver)"{-s=,--storage-driver=}"[Storage driver to use]:driver:(aufs btrfs devicemapper overlay overlay2 vfs zfs)" \
"($help)--selinux-enabled[Enable selinux support]" \
@@ -2795,22 +2789,6 @@ __docker_subcommand() {
"($help)--validate[Validate daemon configuration and exit]" && ret=0
case $state in
- (cluster-store)
- if compset -P '*://'; then
- _message 'host:port' && ret=0
- else
- store=('consul' 'etcd' 'zk')
- _describe -t cluster-store "Cluster Store" store -qS "://" && ret=0
- fi
- ;;
- (cluster-store-options)
- if compset -P '*='; then
- _files && ret=0
- else
- opts=('discovery.heartbeat' 'discovery.ttl' 'kv.cacertfile' 'kv.certfile' 'kv.keyfile' 'kv.path')
- _describe -t cluster-store-opts "Cluster Store Options" opts -qS "=" && ret=0
- fi
- ;;
(users-groups)
if compset -P '*:'; then
_groups && ret=0
@@ -3095,6 +3073,7 @@ _docker() {
_arguments $(__docker_arguments) -C \
"(: -)"{-h,--help}"[Print usage]" \
"($help)--config[Location of client config files]:path:_directories" \
+ "($help -c --context)"{-c=,--context=}"[Execute the command in a docker context]:context:__docker_complete_contexts" \
"($help -D --debug)"{-D,--debug}"[Enable debug mode]" \
"($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \
"($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \
@@ -3110,7 +3089,8 @@ _docker() {
local host=${opt_args[-H]}${opt_args[--host]}
local config=${opt_args[--config]}
- local docker_options="${host:+--host $host} ${config:+--config $config}"
+ local context=${opt_args[-c]}${opt_args[--context]}
+ local docker_options="${host:+--host $host} ${config:+--config $config} ${context:+--context $context} "
case $state in
(command)
diff --git a/plugins/docker/docker.plugin.zsh b/plugins/docker/docker.plugin.zsh
index 9c8ad8a28..8684a9785 100644
--- a/plugins/docker/docker.plugin.zsh
+++ b/plugins/docker/docker.plugin.zsh
@@ -1,39 +1,33 @@
alias dbl='docker build'
-alias dpu='docker pull'
-alias dtop='docker top'
-
-# docker containers
alias dcin='docker container inspect'
-alias dlo='docker container logs'
alias dcls='docker container ls'
alias dclsa='docker container ls -a'
-alias dpo='docker container port'
-alias dr='docker container run'
-alias drit='docker container run -it'
-alias drm='docker container rm'
-alias 'drm!'='docker container rm -f'
-alias dst='docker container start'
-alias dstp='docker container stop'
-alias dxc='docker container exec'
-alias dxcit='docker container exec -it'
-
-# docker images
alias dib='docker image build'
alias dii='docker image inspect'
alias dils='docker image ls'
alias dipu='docker image push'
alias dirm='docker image rm'
alias dit='docker image tag'
-
-# docker network
+alias dlo='docker container logs'
alias dnc='docker network create'
alias dncn='docker network connect'
alias dndcn='docker network disconnect'
alias dni='docker network inspect'
alias dnls='docker network ls'
alias dnrm='docker network rm'
-
-# docker volume
+alias dpo='docker container port'
+alias dpu='docker pull'
+alias dr='docker container run'
+alias drit='docker container run -it'
+alias drm='docker container rm'
+alias 'drm!'='docker container rm -f'
+alias dst='docker container start'
+alias drs='docker container restart'
+alias dsta='docker stop $(docker ps -q)'
+alias dstp='docker container stop'
+alias dtop='docker top'
alias dvi='docker volume inspect'
alias dvls='docker volume ls'
alias dvprune='docker volume prune'
+alias dxc='docker container exec'
+alias dxcit='docker container exec -it'