Skip to content

Commit 1ed7ef9

Browse files
authored
basic docker compose support: up down stop (#979)
1 parent e380c8a commit 1ed7ef9

File tree

1 file changed

+81
-1
lines changed

1 file changed

+81
-1
lines changed

custom-completions/docker/docker-completions.nu

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,23 @@ def "nu-complete docker pull" [] {
1717
[always, missing, never]
1818
}
1919

20+
def "nu-complete docker remove image" [] {
21+
[local, all]
22+
}
23+
2024
def "nu-complete local files" [] {
2125
^ls | lines
2226
}
2327

28+
def "nu-complete docker compose ps" [] {
29+
^docker compose ps -a --format "{{.ID}} {{.Names}}" | lines
30+
| parse "{value} {description}"
31+
}
32+
33+
def "nu-complete docker compose service status" [] {
34+
[paused restarting removing running dead created exited]
35+
}
36+
2437
# Log in to a Docker registry
2538
export extern "docker login" [
2639
server?: string #Docker registry URL
@@ -514,6 +527,73 @@ export extern "docker buildx" [
514527
--builder: string #Override the configured builder instance (default "default")
515528
]
516529

530+
# Stop and remove containers, networks
531+
export extern "docker compose down" [
532+
--dry-run #Execute command in dry run mode
533+
--remove-orphans #Remove containers for services not defined in the Compose file
534+
--rmi: string@"nu-complete docker remove image" #Remove images used by services. "local" remove only images that don't have a custom tag ("local"|"all")
535+
--timeout(-t): int #Specify a shutdown timeout in seconds
536+
--volumes(-v) #Remove named volumes declared in the "volumes" section of the Compose file and anonymous volumes attached to containers
537+
]
538+
539+
# List containers
540+
export extern "docker compose ps" [
541+
--all(-a) #Show all stopped containers (including those created by the run command)
542+
--dry-run #Execute command in dry run mode
543+
--filter: string #Filter services by a property (supported filters: status)
544+
--format: string #Format output using a custom template: 'table': Print output in table; format with column headers (default) 'table TEMPLATE': Print output in table; format using the given Go template 'json': Print in JSON format; 'TEMPLATE': Print output using the given Go template; Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates (default "table")
545+
--no-truncate #Don't truncate output
546+
--orphans #Include orphaned services (not declared by project) (default true)
547+
--quite(-q) #Only display IDs
548+
--services #Display services
549+
--status: string@"nu-complete docker compose service status" #Filter services by status. Values: [paused | restarting | removing | running | dead | created | exited]
550+
]
551+
552+
# Stop containers
553+
export extern "docker compose stop" [
554+
--dry-run #Execute command in dry run mode
555+
--timeout(-t): int #Specify a shutdown timeout in seconds
556+
]
557+
558+
# Restart service containers
559+
export extern "docker compose restart" [
560+
--dry-run #Execute command in dry run mode
561+
--no-deps #Don't restart dependent services
562+
--timeout(-t): int #Specify a shutdown timeout in seconds
563+
]
564+
565+
# Create and start containers
566+
export extern "docker compose up" [
567+
--abort-on-container-exit #Stops all containers if any container was stopped. Incompatible with -d/--detach
568+
--abort-on-container-failure #Stops all containers if any container had a non-zero exit code. Incompatible with -d/--detach
569+
--always-recreate-deps #Recreate dependent containers. Incompatible with --no-recreate
570+
--attach: string #Restrict attaching to the specified services. Incompatible with --attach-dependencies
571+
--attach-dependencies #Automatically attach to log output of all dependent services
572+
--build #Build images before starting containers
573+
--detach(-d) #Detached mode: Run containers in the background
574+
--dry-run #Execute command in dry run mode
575+
--exit-code-from: string #Return the exit code of the selected service container. Implies --abort-on-container-exit
576+
--force-recreate #Recreate containers even if their configuration and image haven't changed
577+
--menu #Enable interactive shortcuts when running attached. Incompatible with --detach. Can also be enable/disable
578+
--no-attach: string #Do not attach (stream logs) to the specified services
579+
--no-build #Don't build an image, even if it's policy
580+
--no-color #Produce monochrome output
581+
--no-deps #Don't start linked services
582+
--no-log-prefix #Don't print prefix in logs
583+
--no-recreate #If containers already exist, don't recreate them. Incompatible with --force-recreate
584+
--no-start #Don't start the services after creating them
585+
--pull: string@"nu-complete docker pull" #Pull image before running ("always"|"missing"|"never") (default "policy")
586+
--quite-pull #Pull without printing progress information
587+
--remove-orphans #Remove containers for services not defined in the Compose file
588+
--renew-anon-volumes(-V) #Recreate anonymous volumes instead of retrieving data from the previous containers
589+
# --scale: scale #Scale SERVICE to NUM instances. Overrides the scale setting in the Compose file if present
590+
--timeout(-t): int #Use this timeout in seconds for container shutdown when attached or when containers are already running
591+
--timestamps #Show timestamps
592+
--wait #Wait for services to be running|healthy. Implies detached mode
593+
--wait-timeout: int #Maximum duration to wait for the project to be running|healthy
594+
--watch(-w) #Watch source code and rebuild|refresh containers when files are updated
595+
]
596+
517597
# An open-source container management platform.
518598
export extern "docker" [
519599
--config: string #Location of client config files (default "/root/.docker")
@@ -595,4 +675,4 @@ export alias "docker push" = docker image push
595675
export alias "docker save" = docker image save
596676

597677
# Inspect changes to files or directories on a container's filesystem
598-
export alias "docker events" = docker system events
678+
export alias "docker events" = docker system events

0 commit comments

Comments
 (0)