mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 22:57:46 +00:00
added docker scripts
This commit is contained in:
parent
3f44d7238b
commit
cc301bf342
3 changed files with 41 additions and 0 deletions
16
docker/README.md
Normal file
16
docker/README.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
### Docker
|
||||
|
||||
This directory contains few simple scripts to simplify docker workflow in nushell
|
||||
|
||||
### Deployment
|
||||
|
||||
source the scripts in startup section of your `config.toml` file
|
||||
|
||||
### Usage
|
||||
* docker.nu - Wrapper around regular docker command, returns a formatted nushell table
|
||||
* compose.nu - Finds compose files of all running containers and then stops them via `docker-compose down`
|
||||
|
||||
### Notes
|
||||
* Both commands assume the user is a mamber of `docker` group, if that is not the case prepend the commands with `sudo`
|
||||
|
||||
* docker.nu should be sourced before compose.nu in your `config.toml` file as the latter uses the former
|
14
docker/compose.nu
Normal file
14
docker/compose.nu
Normal file
|
@ -0,0 +1,14 @@
|
|||
# stops all running containers via their compose files
|
||||
def compose [] {
|
||||
docker ps|
|
||||
each {
|
||||
docker inspect $it.ID|
|
||||
get Config.Labels|
|
||||
select 'com.docker.compose.project.working_dir' 'com.docker.compose.project.config_files'|
|
||||
rename dir file
|
||||
}|
|
||||
uniq|
|
||||
each {
|
||||
docker-compose -f (build-string $it.dir '/' $it.file) down
|
||||
}
|
||||
}
|
11
docker/docker.nu
Normal file
11
docker/docker.nu
Normal file
|
@ -0,0 +1,11 @@
|
|||
# docker wrapper that returns a nushell table
|
||||
def docker [
|
||||
...args:string # command to be passed to the real docker command
|
||||
] {
|
||||
^docker $args --format='{{json .}}'|
|
||||
lines|
|
||||
each {
|
||||
$it|
|
||||
from json
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue