diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..fc4cca3 --- /dev/null +++ b/docker/README.md @@ -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 \ No newline at end of file diff --git a/docker/compose.nu b/docker/compose.nu new file mode 100644 index 0000000..313aca7 --- /dev/null +++ b/docker/compose.nu @@ -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 + } +} diff --git a/docker/docker.nu b/docker/docker.nu new file mode 100644 index 0000000..d4621fc --- /dev/null +++ b/docker/docker.nu @@ -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 + } +}