From 68955f17ad5fe1cc4461868b2b2d059976d43dfb Mon Sep 17 00:00:00 2001 From: ctroncoso Date: Fri, 13 Feb 2015 09:49:54 -0300 Subject: docker containers based on defined names docker container autocomplete listing uses containers ID instead of names. Most users identify their containers by name. ID is only needed and used on a dynamic environment more suited in scripts. --- plugins/docker/_docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/docker/_docker') diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 880b6faa6..14bad1e7e 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -11,7 +11,7 @@ # Output a selectable list of all running docker containers __docker_containers() { declare -a cont_cmd - cont_cmd=($(docker ps | awk 'NR>1{print $1":[CON("$1")"$2"("$3")]"}')) + cont_cmd=($(docker ps | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}')) _describe 'containers' cont_cmd } -- cgit v1.2.3-70-g09d2 From cd36deda23a1f6f53ba910077b22c200fb820299 Mon Sep 17 00:00:00 2001 From: Karsten Kosmala Date: Mon, 16 Feb 2015 12:04:37 +0100 Subject: added stats command to docker plugin --- plugins/docker/_docker | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'plugins/docker/_docker') diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 880b6faa6..df8319ea7 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -219,6 +219,10 @@ __start() { __docker_containers } +__stats() { + __docker_containers +} + __stop() { _arguments \ '(-t,--time=)'{-t,--time=}'[Number of seconds to wait for the container to stop before killing it.]' @@ -280,6 +284,7 @@ _1st_arguments=( "save":"Save an image to a tar archive" "search":"Search for an image in the docker index" "start":"Start a stopped container" + "stats":"Display a live stream of one or more containers' resource usage statistics" "stop":"Stop a running container" "tag":"Tag an image into a repository" "top":"Lookup the running processes of a container" @@ -351,6 +356,8 @@ case "$words[1]" in __save ;; search) __search ;; + stats) + __stats ;; start) __start ;; stop) -- cgit v1.2.3-70-g09d2 From 2dbf9951d92e1f63672da3721b23b1d53b5cfa31 Mon Sep 17 00:00:00 2001 From: Kennedy Oliveira Date: Wed, 29 Apr 2015 15:17:11 -0300 Subject: Fixing some issues where show repeated weird values, and fixed commands that need the container autocomplete without being running, like start, now it autocompletes showing all the containers so you can start without knowing the right name --- plugins/docker/_docker | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'plugins/docker/_docker') diff --git a/plugins/docker/_docker b/plugins/docker/_docker index aadc9c61d..fd459a0ca 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -12,7 +12,16 @@ __docker_containers() { declare -a cont_cmd cont_cmd=($(docker ps | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}')) - _describe 'containers' cont_cmd + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'containers' cont_cmd +} + +# Output a selectable list of all containers, even not running +__docker_all_containers() { + declare -a cont_cmd + cont_cmd=($(docker ps -a | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}')) + if [[ 'X$cont_cmd' != 'X' ]] + _describe 'containers' cont_cmd } # output a selectable list of all docker images @@ -57,7 +66,7 @@ __diff() { __docker_containers } -__events() { +__events() { _arguments \ '--since=[Show previously created events and then stream.]' } @@ -98,10 +107,12 @@ __insert() { __inspect() { __docker_images - __docker_containers + __docker_all_containers } __kill() { + _arguments \ + '(-s,--signal=)'{-s,--signal=}'[KILL Signal]' __docker_containers } @@ -162,7 +173,7 @@ __rm() { '(-f,--force=)'{-f,--force=}'[Force removal of running container]' \ '(-l,--link=)'{-l,--link=}'[Remove the specified link and not the underlying container]' \ '(-v,--volumes=)'{-v,--volumes=}'[Remove the volumes associated to the container]' - __docker_containers + __docker_all_containers } __rmi() { @@ -216,7 +227,7 @@ __start() { _arguments \ '(-a,--attach=)'{-a,--attach=}'[Attach container''s stdout/stderr and forward all signals to the process]' \ '(-i,--interactive=)'{-i,--interactive=}'[Attach container''s stdin]' - __docker_containers + __docker_all_containers } __stats() { -- cgit v1.2.3-70-g09d2 From 557dc09d71e489790742ed8603e929edb48fb071 Mon Sep 17 00:00:00 2001 From: UserTaken Date: Thu, 11 Jun 2015 00:21:45 -0700 Subject: More run and create options --- plugins/docker/_docker | 90 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 71 insertions(+), 19 deletions(-) (limited to 'plugins/docker/_docker') diff --git a/plugins/docker/_docker b/plugins/docker/_docker index fd459a0ca..bd494ecaa 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -36,7 +36,7 @@ __docker_images() { # --------------------------- __attach() { _arguments \ - '--no-stdin[Do not attach stdin]' \ + '--no-stdin[Do not attach STDIN]' \ '--sig-proxy[Proxify all received signal to the process (even in non-tty mode)]' __docker_containers } @@ -55,6 +55,7 @@ __commit() { '(-a,--author=)'{-a,--author=}'[Author (eg. "John Hannibal Smith "]' \ '(-m,--message=)'{-m,--message=}'[Commit message]' \ '--run=[Config automatically applied when the image is run.]' + '(-p,--pause=)'{-p,--pause=}'[Pause container during commit]' \ __docker_containers } @@ -62,6 +63,48 @@ __cp() { __docker_containers } +__create() { + _arguments \ + '(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \ + '(-a,--attach=)'{-a,--attach=}'[Attach to STDIN, STDOUT or STDERR]' \ + '--add-host=[Add a custom host-to-IP mapping]' \ + '--cap-add=[Add Linux capabilities]' \ + '--cap-drop=[Drop Linux capabilities]' \ + '(-c,--cpu-shares=)'{-c,--cpu-shares=}':[CPU shares (relative weight)]' \ + '--cidfile=[Write the container ID to the file]' \ + '--device=[Add a host device to the container]' \ + '--dns=[Set custom dns servers]' \ + '--dns-search=[Set custom DNS search domains]' \ + '(-e,--env=)'{-e,--env=}'[Set environment variables]' \ + '--env-file=[Read in a file of environment variables]' \ + '--entrypoint=[Overwrite the default entrypoint of the image]' \ + '--expose=[Expose a port from the container without publishing it to your host]' \ + '(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \ + '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \ + '--ipc=[IPC namespace to use]' \ + '(-l,--label=)'{-l,--label=}'[Set meta data on a container]' \ + '--link=[Add link to another container (name:alias)]' \ + '--log-driver=[Logging driver for the container]' \ + '--lxc-conf=[Add custom LXC options]' \ + '--mac-address=[Container MAC address (e.g. 92:d0:c6:0a:29:33)]' \ + '(-m,--memory=)'{-m,--memory=}'[Memory limit (format: , where unit = b, k, m or g)]' \ + '--net=[Set the Network mode for the container]' \ + '--name=[Assign a name to the container]' \ + '--pid=[PID namespace to use]' \ + '(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort/protocol)]' \ + '--privileged=[Give extended privileges to this container]' \ + '--restart=[Restart policy to apply when a container exits]' \ + '--security-opt=[Security Options]' \ + '--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \ + '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \ + '(-u,--user=)'{-u,--user=}'[Username or UID]' \ + '--ulimit=[Ulimit options]' \ + '(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. -v /host:/container or -v /container)]' \ + '--volumes-from=[Mount volumes from the specified container(s)]' \ + '(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]' + __docker_images +} + __diff() { __docker_containers } @@ -100,11 +143,6 @@ __info() { # no arguments } -__insert() { - __docker_images - _arguments '*:files:_files' -} - __inspect() { __docker_images __docker_all_containers @@ -185,28 +223,42 @@ __rmi() { __run() { _arguments \ '(-P,--publish-all=)'{-P,--publish-all=}'[Publish all exposed ports to the host interfaces]' \ - '(-a,--attach=)'{-a,--attach=}'[Attach to stdin, stdout or stderr.]' \ - '(-c,--cpu-shares=)'{-c,--cpu-shares=}': CPU shares (relative weight)]' \ + '(-a,--attach=)'{-a,--attach=}'[Attach to STDIN, STDOUT or STDERR]' \ + '--add-host=[Add a custom host-to-IP mapping]' \ + '--cap-add=[Add Linux capabilities]' \ + '--cap-drop=[Drop Linux capabilities]' \ + '(-c,--cpu-shares=)'{-c,--cpu-shares=}':[CPU shares (relative weight)]' \ '--cidfile=[Write the container ID to the file]' \ - '(-d,--detach=)'{-d,--detach=}'[Detached mode: Run container in the background, print new container id]' \ + '(-d,--detach=)'{-d,--detach=}'[Run container in the background, print new container id]' \ + '--device=[Add a host device to the container]' \ '--dns=[Set custom dns servers]' \ + '--dns-search=[Set custom DNS search domains]' \ '(-e,--env=)'{-e,--env=}'[Set environment variables]' \ + '--env-file=[Read in a file of environment variables]' \ '--entrypoint=[Overwrite the default entrypoint of the image]' \ '--expose=[Expose a port from the container without publishing it to your host]' \ '(-h,--hostname=)'{-h,--hostname=}'[Container host name]' \ - '(-i,--interactive=)'{-i,--interactive=}'[Keep stdin open even if not attached]' \ + '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \ + '--ipc=[IPC namespace to use]' \ + '(-l,--label=)'{-l,--label=}'[Set meta data on a container]' \ '--link=[Add link to another container (name:alias)]' \ - '--lxc-conf=[Add custom lxc options -lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"]' \ + '--log-driver=[Logging driver for the container]' \ + '--lxc-conf=[Add custom LXC options]' \ + '--mac-address=[Container MAC address (e.g. 92:d0:c6:0a:29:33)]' \ '(-m,--memory=)'{-m,--memory=}'[Memory limit (format: , where unit = b, k, m or g)]' \ - '(-n,--networking=)'{-n,--networking=}'[Enable networking for this container]' \ + '--net=[Set the Network mode for the container]' \ '--name=[Assign a name to the container]' \ - '(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort) (use "docker port" to see the actual mapping)]' \ + '--pid=[PID namespace to use]' \ + '(-p,--publish=)'{-p,--publish=}'[Publish a container''s port to the host (format: ip:hostPort:containerPort/protocol)]' \ '--privileged=[Give extended privileges to this container]' \ + '--restart=[Restart policy to apply when a container exits]' \ '--rm=[Automatically remove the container when it exits (incompatible with -d)]' \ + '--security-opt=[Security Options]' \ '--sig-proxy=[Proxify all received signal to the process (even in non-tty mode)]' \ '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-tty]' \ '(-u,--user=)'{-u,--user=}'[Username or UID]' \ - '(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]' \ + '--ulimit=[Ulimit options]' \ + '(-v,--volume=)'{-v,--volume=}'[Bind mount a volume (e.g. -v /host:/container or -v /container)]' \ '--volumes-from=[Mount volumes from the specified container(s)]' \ '(-w,--workdir=)'{-w,--workdir=}'[Working directory inside the container]' __docker_images @@ -225,8 +277,8 @@ __save() { __start() { _arguments \ - '(-a,--attach=)'{-a,--attach=}'[Attach container''s stdout/stderr and forward all signals to the process]' \ - '(-i,--interactive=)'{-i,--interactive=}'[Attach container''s stdin]' + '(-a,--attach=)'{-a,--attach=}'[Attach container''s STDOUT/STDERR and forward all signals to the process]' \ + '(-i,--interactive=)'{-i,--interactive=}'[Attach container''s STDIN]' __docker_all_containers } @@ -271,6 +323,7 @@ _1st_arguments=( "build":"Build a container from a Dockerfile" "commit":"Create a new image from a container's changes" "cp":"Copy files/folders from the containers filesystem to the host path" + "create":"Create new container without running it" "diff":"Inspect changes on a container's filesystem" "events":"Get real time events from the server" "export":"Stream the contents of a container as a tar archive" @@ -278,7 +331,6 @@ _1st_arguments=( "images":"List images" "import":"Create a new filesystem image from the contents of a tarball" "info":"Display system-wide information" - "insert":"Insert a file in an image" "inspect":"Return low-level information on a container" "kill":"Kill a running container" "load":"Load an image from a tar archive" @@ -321,6 +373,8 @@ case "$words[1]" in __commit ;; cp) __cp ;; + create) + __create ;; diff) __diff ;; events) @@ -335,8 +389,6 @@ case "$words[1]" in __import ;; info) __info ;; - insert) - __insert ;; inspect) __inspect ;; kill) -- cgit v1.2.3-70-g09d2 From 55b1a2befe3d041b54c6aa542bd11734db31a6d5 Mon Sep 17 00:00:00 2001 From: UserTaken Date: Sat, 13 Jun 2015 16:30:18 -0700 Subject: Update _docker --- plugins/docker/_docker | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'plugins/docker/_docker') diff --git a/plugins/docker/_docker b/plugins/docker/_docker index bd494ecaa..25f55beca 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -52,11 +52,10 @@ __build() { __commit() { _arguments \ - '(-a,--author=)'{-a,--author=}'[Author (eg. "John Hannibal Smith "]' \ + '(-a,--author=)'{-a,--author=}'[Author (e.g. "John Hannibal Smith ")]' \ + '(-c,--change=)'{-c,--change=}'[Apply Dockerfile instruction to the created image]' \ '(-m,--message=)'{-m,--message=}'[Commit message]' \ - '--run=[Config automatically applied when the image is run.]' '(-p,--pause=)'{-p,--pause=}'[Pause container during commit]' \ - __docker_containers } __cp() { @@ -70,7 +69,8 @@ __create() { '--add-host=[Add a custom host-to-IP mapping]' \ '--cap-add=[Add Linux capabilities]' \ '--cap-drop=[Drop Linux capabilities]' \ - '(-c,--cpu-shares=)'{-c,--cpu-shares=}':[CPU shares (relative weight)]' \ + '--cpuset-cpus=[CPUs in which to allow execution (0-3, 0,1)]' \ + '(-c,--cpu-shares=)'{-c,--cpu-shares=}'[CPU shares (relative weight)]' \ '--cidfile=[Write the container ID to the file]' \ '--device=[Add a host device to the container]' \ '--dns=[Set custom dns servers]' \ @@ -227,7 +227,8 @@ __run() { '--add-host=[Add a custom host-to-IP mapping]' \ '--cap-add=[Add Linux capabilities]' \ '--cap-drop=[Drop Linux capabilities]' \ - '(-c,--cpu-shares=)'{-c,--cpu-shares=}':[CPU shares (relative weight)]' \ + '--cpuset-cpus=[CPUs in which to allow execution (0-3, 0,1)]' \ + '(-c,--cpu-shares=)'{-c,--cpu-shares=}'[CPU shares (relative weight)]' \ '--cidfile=[Write the container ID to the file]' \ '(-d,--detach=)'{-d,--detach=}'[Run container in the background, print new container id]' \ '--device=[Add a host device to the container]' \ -- cgit v1.2.3-70-g09d2