├── bin ├── docker-last ├── docker-container-volumes ├── boot2docker-timesync ├── docker-pid ├── docker-ip ├── docker-lint ├── docker-purge-unnamed-images ├── dive ├── docker-here ├── docker-delete-stopped-containers ├── docker-remove-dangling-images ├── docker-ps-cleanup ├── docker-superclean ├── docker-update-all-images ├── docker-tags ├── fzf-docker-stop ├── fzf-docker-rm ├── docker-clean ├── fzf-docker-attach ├── docker-create-backup-container ├── docker-shell ├── docker-showipc ├── docker-check-for-image-update ├── docker-stopc ├── docker-runinc └── docker-runc ├── .gitignore ├── .github ├── workflows │ ├── awesomebot.yml │ └── mega-linter.yml └── PULL_REQUEST_TEMPLATE.md ├── Contributing.md ├── CodeOfConduct.md ├── docker-helpers.plugin.zsh ├── ReadMe.md └── LICENSE /bin/docker-last: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Author: Joe Block 4 | # License: Apache 2 (See LICENSE file) 5 | 6 | exec docker ps -l -q 7 | -------------------------------------------------------------------------------- /bin/docker-container-volumes: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # From http://www.tech-d.net/2014/05/05/docker-quicktip-5-backing-up-volumes/ 4 | 5 | exec docker inspect --format='-v :/volData ' $* 6 | -------------------------------------------------------------------------------- /bin/boot2docker-timesync: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Author: Joe Block 4 | # License: Apache 2 (See LICENSE file) 5 | 6 | exec boot2docker ssh sudo ntpclient -s -h pool.ntp.org 7 | -------------------------------------------------------------------------------- /bin/docker-pid: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Get pid of a docker container 4 | # 5 | # Copyright 2021, Joe Block 6 | 7 | exec docker inspect --format "{{ .State.Pid }}" "$1" 8 | -------------------------------------------------------------------------------- /bin/docker-ip: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Get the IP of a docker container 4 | # 5 | # Copyright 2021, Joe Block 6 | 7 | exec docker inspect --format "{{ .NetworkSettings.IPAddress }}" "$1" 8 | -------------------------------------------------------------------------------- /bin/docker-lint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Lint a dockerfile with hadolint 4 | # 5 | # Copyright 2020, Joe Block 6 | 7 | set -o pipefail 8 | 9 | exec docker run --rm -i hadolint/hadolint < "$@" 10 | -------------------------------------------------------------------------------- /bin/docker-purge-unnamed-images: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Author: Joe Block 4 | # License: Apache 2 (See LICENSE file) 5 | 6 | set -o pipefail 7 | 8 | docker images | \ 9 | grep \ | \ 10 | awk '{print $3}' | \ 11 | xargs docker rmi 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Regular ignores 2 | *.bak 3 | *.bz2 4 | *.gz 5 | *.lock 6 | *.log 7 | *.pyc 8 | *.pyo 9 | *.rpm 10 | *.sublime-project 11 | *.sublime-workspace 12 | *.swp 13 | *.tar 14 | *.tgz 15 | *deploy.log 16 | .*~ 17 | .DS_Store 18 | .kitchen 19 | .rake_tasks 20 | .rbenv* 21 | -------------------------------------------------------------------------------- /bin/dive: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Wrap dive 4 | # 5 | # Copyright 2020, Joe Block 6 | 7 | set -o pipefail 8 | 9 | exec docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock \ 10 | -e DOCKER_API_VERSION=1.37 wagoodman/dive:latest $@ 11 | -------------------------------------------------------------------------------- /bin/docker-here: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Build and run an ephemeral docker image without making me remember the 4 | # commands to do so. Based on a discussion on hangops slack. 5 | 6 | IMAGE_ID=$(docker build -q .) 7 | docker run --rm -it "$IMAGE_ID" "$@" 8 | retval=$? 9 | docker rmi $IMAGE_ID 10 | exit $retval 11 | -------------------------------------------------------------------------------- /bin/docker-delete-stopped-containers: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Author: Joe Block 4 | # License: Apache 2 (See LICENSE file) 5 | 6 | CONTAINER_LIST=$(docker ps -a -q) 7 | 8 | if [ -n "${CONTAINER_LIST}" ]; then 9 | exec docker rm ${CONTAINER_LIST} 10 | else 11 | echo "No containers to clean up" 12 | fi 13 | -------------------------------------------------------------------------------- /.github/workflows/awesomebot.yml: -------------------------------------------------------------------------------- 1 | name: Check links in README.md 2 | 3 | on: 4 | push: 5 | branches: [ '*' ] 6 | pull_request: 7 | branches: [ '*' ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v1 16 | - uses: docker://dkhamsing/awesome_bot:latest 17 | with: 18 | args: /github/workspace/ReadMe.md --allow-dupe --allow-redirect --request-delay 1 --white-list https://github,https://img.shields.io,http://www.tech-d.net 19 | -------------------------------------------------------------------------------- /bin/docker-remove-dangling-images: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Remove dangling docker images 4 | # 5 | # Copyright 2020, Joe Block 6 | 7 | set -o pipefail 8 | 9 | function docker-remove-dangling-images { 10 | if [[ $(uname -s) -eq "Darwin" ]]; then 11 | exec docker images -f 'dangling=true' -q | awk '{print $1}' | xargs -n 1 docker rmi 12 | else 13 | exec docker images -f 'dangling=true' -q | awk '{print $1}' | xargs -r -n 1 docker rmi 14 | fi 15 | } 16 | 17 | docker-remove-dangling-images 18 | -------------------------------------------------------------------------------- /bin/docker-ps-cleanup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Remove exited containers from ps listing 4 | # 5 | # Copyright 2020, Joe Block 6 | 7 | set -o pipefail 8 | 9 | function docker-ps-cleanup { 10 | if [[ $(uname -s) -eq "Darwin" ]]; then 11 | exec docker ps -a --format '{{.Names}} {{.Status}}' | grep 'Exited' | awk '{print $1}' | xargs -n 1 docker rmi 12 | else 13 | exec docker ps -a --format '{{.Names}} {{.Status}}' | grep 'Exited' | awk '{print $1}' | xargs -r -n 1 docker rmi 14 | fi 15 | } 16 | 17 | docker-ps-cleanup 18 | -------------------------------------------------------------------------------- /bin/docker-superclean: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Author: Joe Block 4 | # License: Apache 2 (See LICENSE file) 5 | 6 | echo "Cleaning stale containers" 7 | CONTAINER_LIST=$(docker ps -a -q) 8 | if [ -n "${CONTAINER_LIST}" ]; then 9 | docker rm ${CONTAINER_LIST} 10 | else 11 | echo "No stale containers to clean up" 12 | fi 13 | 14 | echo "Cleaning stale images" 15 | IMAGE_LIST=$(docker images -q -f dangling=true) 16 | if [ -n "${IMAGE_LIST}" ]; then 17 | docker rmi ${IMAGE_LIST} 18 | else 19 | echo "No stale images to clean" 20 | fi 21 | 22 | docker images | grep "" | awk '{print $3}' | xargs docker rmi 23 | -------------------------------------------------------------------------------- /bin/docker-update-all-images: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Update all the images on a machine, in increasing size order 4 | # 5 | # Copyright 2019-2020, Joe Block 6 | 7 | set -o pipefail 8 | 9 | function docker-update-images { 10 | if [[ $(uname -s) -eq "Darwin" ]]; then 11 | docker images | grep -v REPOSITORY | grep -v none | awk '{print $7 " " $1":"$2}' | sort -h | awk '{print $2}'| xargs -n 1 docker pull 12 | else 13 | docker images | grep -v REPOSITORY | grep -v none | awk '{print $7 " " $1":"$2}' | sort -h | awk '{print $2}'| xargs -r -n 1 docker pull 14 | fi 15 | } 16 | 17 | docker-update-images 18 | -------------------------------------------------------------------------------- /bin/docker-tags: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | myname=$(basename "$0") 4 | if [[ $# -lt 1 ]]; then 5 | cat << HELP 6 | 7 | $myname -- list all tags for a Docker image on a remote registry. 8 | 9 | EXAMPLE: 10 | - list all tags for ubuntu: 11 | $myname ubuntu 12 | 13 | - list all php tags containing apache: 14 | $myname php apache 15 | 16 | HELP 17 | exit 0 18 | fi 19 | 20 | image="$1" 21 | tags=$(wget -q https://registry.hub.docker.com/v1/repositories/${image}/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}') 22 | 23 | if [[ -n "$2" ]]; then 24 | tags=$( echo "${tags}" | grep "$2" ) 25 | fi 26 | 27 | echo "${tags}" 28 | -------------------------------------------------------------------------------- /Contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | **docker-helpers.zshplugin** is a collection of helper scripts for docker. 4 | 5 | ## Contribution Guidelines 6 | 7 | - **To add a helper script:** Submit a pull request. 8 | - **To remove a script:** Open an issue to discuss the removal or create a pull request. 9 | 10 | Please include an entry in the credits section of README.md for any scripts in your PRs so authors get their work credited correctly. Please keep the credits in alphabetical order by script name. 11 | 12 | Please sign off on your commits. You can use `git commit --amend --no-edit --signoff` to amend an existing commit, and you can find more details about signing off commits on the DCO GitHub action page [here](https://probot.github.io/apps/dco/) -------------------------------------------------------------------------------- /bin/fzf-docker-stop: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # From https://betterprogramming.pub/boost-your-command-line-productivity-with-fuzzy-finder-985aa162ba5d 4 | 5 | set -o pipefail 6 | if [[ -n "$DEBUG" ]]; then 7 | set -x 8 | fi 9 | 10 | function fail { 11 | printf '%s' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way. 12 | exit "${2-1}" ## Return a code specified by $2 or 1 by default. 13 | } 14 | 15 | # Select a docker container to stop 16 | function ds() { 17 | local cid 18 | cid=$(docker ps | sed 1d | fzf -q "$1" | awk '{print $1}') 19 | 20 | [ -n "$cid" ] && docker stop "$cid" 21 | } 22 | 23 | if (which fzf &> /dev/null); then 24 | # shellcheck disable=SC2068 25 | ds $@ 26 | else 27 | fail 'fzf is not installed.' 28 | fi -------------------------------------------------------------------------------- /bin/fzf-docker-rm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # From https://betterprogramming.pub/boost-your-command-line-productivity-with-fuzzy-finder-985aa162ba5d 4 | 5 | set -o pipefail 6 | if [[ -n "$DEBUG" ]]; then 7 | set -x 8 | fi 9 | 10 | function fail { 11 | printf '%s' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way. 12 | exit "${2-1}" ## Return a code specified by $2 or 1 by default. 13 | } 14 | 15 | # Select a docker container to remove with fzf 16 | function drm() { 17 | local cid 18 | cid=$(docker ps -a | sed 1d | fzf -q "$1" | awk '{print $1}') 19 | 20 | [ -n "$cid" ] && docker rm "$cid" 21 | } 22 | 23 | if (which fzf &> /dev/null); then 24 | # shellcheck disable=SC2068 25 | drm $@ 26 | else 27 | fail 'fzf is not installed.' 28 | fi -------------------------------------------------------------------------------- /bin/docker-clean: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Clean up docker 4 | # 5 | # Copyright 2022, Joe Block 6 | 7 | set -o pipefail 8 | if [[ -n "$DEBUG" ]]; then 9 | set -x 10 | fi 11 | 12 | function debug() { 13 | if [[ -n "$DEBUG" ]]; then 14 | echo "$@" 15 | fi 16 | } 17 | 18 | function fail() { 19 | printf '%s\n' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way. 20 | exit "${2-1}" ## Return a code specified by $2 or 1 by default. 21 | } 22 | 23 | function has() { 24 | # Check if a command is in $PATH 25 | which "$@" > /dev/null 2>&1 26 | } 27 | 28 | if has docker; then 29 | docker ps -a | grep 'Exited' | awk '{print $1}' | xargs docker rm 30 | docker images -aq | xargs docker rmi 31 | else 32 | fail "Can't find docker in your PATH" 33 | fi -------------------------------------------------------------------------------- /bin/fzf-docker-attach: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # From https://betterprogramming.pub/boost-your-command-line-productivity-with-fuzzy-finder-985aa162ba5d 4 | 5 | set -o pipefail 6 | if [[ -n "$DEBUG" ]]; then 7 | set -x 8 | fi 9 | 10 | function fail { 11 | printf '%s' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way. 12 | exit "${2-1}" ## Return a code specified by $2 or 1 by default. 13 | } 14 | 15 | 16 | # Select a docker container to start and attach to 17 | function da() { 18 | local cid 19 | cid=$(docker ps -a | sed 1d | fzf -1 -q "$1" | awk '{print $1}') 20 | 21 | [ -n "$cid" ] && docker start "$cid" && docker attach "$cid" 22 | } 23 | 24 | if (which fzf &> /dev/null); then 25 | # shellcheck disable=SC2068 26 | da $@ 27 | else 28 | fail 'fzf is not installed.' 29 | fi -------------------------------------------------------------------------------- /bin/docker-create-backup-container: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # From http://www.tech-d.net/2014/05/05/docker-quicktip-5-backing-up-volumes/ 4 | 5 | if [ $# != 2 ]; then 6 | echo "Usage: $0 containername imagename" 7 | exit 1 8 | fi 9 | 10 | volumes_args() { 11 | docker inspect --format='-v :/volData ' ${1} 12 | } 13 | 14 | volume_hostPaths() { 15 | docker inspect --format=' ' ${1} 16 | } 17 | 18 | volConfig="" 19 | paths=() # store host paths so we can check if it's already used 20 | for container in $(docker ps -a -q); do 21 | hostPaths=$(volume_hostPaths ${container}) 22 | for hostPath in $hostPaths; do 23 | match=$(echo "${paths[@]:0}" | grep -o ${hostPath}) 24 | if [[ "${match}" == "" ]]; then 25 | paths+=(${hostPath}) 26 | volConfig="${volConfig} $(volumes_args ${container})" 27 | fi 28 | done 29 | done 30 | 31 | docker run -d ${volConfig} --name $1 $2 32 | -------------------------------------------------------------------------------- /bin/docker-shell: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Run a shell in a docker container 4 | # 5 | # Copyright 2021, Joe Block 6 | 7 | STANDARD_DOCKER_IMAGE=${STANDARD_DOCKER_IMAGE:-'debian:buster-slim'} 8 | STANDARD_DOCKER_SHELL=${STANDARD_DOCKER_SHELL:-'bash'} 9 | 10 | if [[ "$1" == "--help" ]]; then 11 | echo "Usage:" 12 | # shellcheck disable=SC2086 13 | echo "$(basename $0) optional-image-name optional-command" 14 | echo "default is to run $STANDARD_DOCKER_SHELL inside $STANDARD_DOCKER_IMAGE" 15 | echo 16 | echo "Mounts current directory in container as /pwd" 17 | exit 0 18 | fi 19 | 20 | if [[ -n "$1" ]]; then 21 | IMAGE="$1" 22 | else 23 | IMAGE="$STANDARD_DOCKER_IMAGE" 24 | fi 25 | if [[ -n "$2" ]]; then 26 | DOCKER_COMMAND="$2" 27 | else 28 | DOCKER_COMMAND="$STANDARD_DOCKER_SHELL" 29 | fi 30 | 31 | exec docker run -v "$(pwd):/pwd" -w "/pwd" --rm -it "$IMAGE" "$DOCKER_COMMAND" 32 | -------------------------------------------------------------------------------- /bin/docker-showipc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Show the IP of a running docker container 4 | # 5 | # From Carlos Alberto's https://medium.com/@calbertts/docker-and-fuzzy-finder-fzf-4c6416f5e0b5 article 6 | # 7 | # Copyright 2019, Carlos Alberto 8 | 9 | set -o pipefail 10 | 11 | showipc() { 12 | export FZF_DEFAULT_OPTS='--height 90% --reverse --border' 13 | local container=$(docker ps -a --format '{{.Names}} => {{.Image}}' | fzf-tmux --reverse --multi | awk -F '\\=>' '{print $1}') 14 | 15 | if [[ $container != '' ]]; then 16 | local network=$(docker inspect $container -f '{{.NetworkSettings.Networks}}' | awk -F 'map\\[|:' '{print $2}') 17 | echo -e "\n \033[1mDocker container:\033[0m" $container 18 | history -s showipc 19 | history -s docker inspect -f "{{.NetworkSettings.Networks.${network}.IPAddress}}" $container 20 | echo -e " \033[1mNetwork:\033[0m" $network 21 | echo -e " \033[1mIP Address:\033[0m" $(docker inspect -f "{{.NetworkSettings.Networks.${network}.IPAddress}}" $container) "\n" 22 | fi 23 | } 24 | 25 | showipc $@ 26 | -------------------------------------------------------------------------------- /bin/docker-check-for-image-update: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Original source: https://mlohr.com/check-for-docker-image-updates/ 3 | # Original Author: Mathias Lohr 4 | # Example usage: 5 | # ./docker-image-update-check.sh gitlab/gitlab-ce update-gitlab.sh 6 | 7 | function has() { 8 | which "$@" > /dev/null 2>&1 9 | } 10 | 11 | IMAGE="$1" 12 | COMMAND="$2" 13 | 14 | if ! has jq; then 15 | echo "'jq' command not found in PATH." 16 | exit 1 17 | fi 18 | 19 | echo "Fetching Docker Hub token..." 20 | token=$(curl --silent "https://auth.docker.io/token?scope=repository:$IMAGE:pull&service=registry.docker.io" | jq -r '.token') 21 | 22 | echo -n "Fetching remote digest... " 23 | digest=$(curl --silent -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \ 24 | -H "Authorization: Bearer $token" \ 25 | "https://registry.hub.docker.com/v2/$IMAGE/manifests/latest" | jq -r '.config.digest') 26 | echo "$digest" 27 | 28 | echo -n "Fetching local digest... " 29 | local_digest=$(docker images -q --no-trunc $IMAGE:latest) 30 | echo "$local_digest" 31 | 32 | if [ "$digest" != "$local_digest" ]; then 33 | echo "Update available. Executing update command..." 34 | ($COMMAND) 35 | else 36 | echo "Already up to date. Nothing to do." 37 | fi 38 | -------------------------------------------------------------------------------- /bin/docker-stopc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Fron https://medium.com/@calbertts/docker-and-fuzzy-finder-fzf-4c6416f5e0b5 4 | # 5 | # Stops and/or removes a docker container 6 | 7 | stopc() { 8 | export FZF_DEFAULT_OPTS='--height 90% --reverse --border' 9 | local container=$(docker ps --format '{{.Names}} => {{.Image}}' | fzf-tmux --reverse --multi | awk -F '\\=>' '{print $1}') 10 | if [[ $container != '' ]]; then 11 | echo -e "\n \033[1mDocker container:\033[0m" $container 12 | printf " \033[1mRemove?: \033[0m" 13 | local cmd=$(echo -e "No\nYes" | fzf-tmux --reverse --multi) 14 | if [[ $cmd != '' ]]; then 15 | if [[ $cmd == 'No' ]]; then 16 | echo -e "\n Stopping $container ...\n" 17 | history -s stopc 18 | history -s docker stop $container 19 | docker stop $container > /dev/null 20 | else 21 | echo -e "\n Stopping $container ..." 22 | history -s stopc 23 | history -s docker stop $container 24 | docker stop $container > /dev/null 25 | 26 | echo -e " Removing $container ...\n" 27 | history -s stopc 28 | history -s docker rm $container 29 | docker rm $container > /dev/null 30 | fi 31 | fi 32 | fi 33 | export FZF_DEFAULT_OPTS="" 34 | } 35 | 36 | stopc $@ 37 | -------------------------------------------------------------------------------- /bin/docker-runinc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # https://medium.com/@calbertts/docker-and-fuzzy-finder-fzf-4c6416f5e0b5 4 | # 5 | # Use fzf to select a running container and run a command in it 6 | 7 | function fail() { 8 | printf '%s\n' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way. 9 | exit "${2-1}" ## Return a code specified by $2 or 1 by default. 10 | } 11 | 12 | function has() { 13 | # Check if a command is in $PATH 14 | which "$@" > /dev/null 2>&1 15 | } 16 | 17 | # shellcheck disable=SC2086,SC2162,SC2199,SC2124 18 | function runinc() { 19 | export FZF_DEFAULT_OPTS='--height 90% --reverse --border' 20 | local container 21 | container=$(docker ps --format '{{.Names}} => {{.Image}}' | fzf-tmux --reverse --multi | awk -F '\\=>' '{print $1}') 22 | if [[ $container != '' ]]; then 23 | echo -e "\n \033[1mDocker container:\033[0m" $container 24 | read -e -p $' \e[1mOptions: \e[0m' -i "-it" options 25 | if [[ $@ == '' ]]; then 26 | read -e -p $' \e[1mCommand: \e[0m' cmd 27 | else 28 | cmd="$@" 29 | fi 30 | echo '' 31 | history -s runinc "$@" 32 | history -s docker exec $options $container $cmd 33 | docker exec $options $container $cmd 34 | echo '' 35 | fi 36 | export FZF_DEFAULT_OPTS="" 37 | } 38 | 39 | # shellcheck disable=SC2068 40 | if has fzf; then 41 | runinc $@ 42 | else 43 | fail "Can't find 'fzf' in your PATH" 44 | fi -------------------------------------------------------------------------------- /CodeOfConduct.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. 4 | 5 | We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion. 6 | 7 | Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. 8 | 9 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. 10 | 11 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. 12 | 13 | This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/) 14 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Description 4 | 5 | 6 | 7 | # Type of changes 8 | 9 | 10 | 11 | - [ ] A helper script 12 | - [ ] A link to an external resource like a blog post or video 13 | - [ ] Text cleanups/updates 14 | 15 | # Checklist 16 | 17 | 18 | 19 | 20 | - [ ] All new and existing tests pass. 21 | - [ ] I have signed off my commits. You can use `git commit --amend --no-edit --signoff` to amend an existing commit, and you can find more details about signing off commits on the DCO GitHub action page [here](https://probot.github.io/apps/dco/) 22 | - [ ] Any scripts added use `#!/usr/bin/env interpreter` instead of potentially platform-specific direct paths (`#!/bin/sh` is the only exception) 23 | - [ ] Scripts are marked executable 24 | - [ ] Scripts _do not_ have a language file extension unless they are meant to be sourced and not run standalone. No one should have to know if a script was written in bash, python, ruby or whatever. Not including file extensions makes it easier to rewrite the script in another language later without having to change every reference to the previous version. 25 | - [ ] I have added a credit line to README.md for the script 26 | - [ ] If there was no author credit in a script added in this PR, I have added one. 27 | - [ ] I have confirmed that the link(s) in my PR are valid. 28 | 29 | # License Acceptance 30 | 31 | - [ ] This repository is Apache version 2.0 licensed (some scripts may have alternate licensing inline in their code) and by making this PR, I am contributing my changes to the repository under the terms of the Apache 2 license. 32 | -------------------------------------------------------------------------------- /.github/workflows/mega-linter.yml: -------------------------------------------------------------------------------- 1 | --- 2 | ########################### 3 | ########################### 4 | ## Linter GitHub Actions ## 5 | ########################### 6 | ########################### 7 | name: Lint Code Base 8 | 9 | # 10 | # Documentation: 11 | # https://help.github.com/en/articles/workflow-syntax-for-github-actions 12 | # 13 | 14 | ############################# 15 | # Start the job on all push # 16 | ############################# 17 | on: 18 | push: 19 | branches-ignore: [main] 20 | # Remove the line above to run when pushing to main 21 | pull_request: 22 | branches: [main] 23 | 24 | ############### 25 | # Set the Job # 26 | ############### 27 | jobs: 28 | build: 29 | # Name the Job 30 | name: Megalint Code Base 31 | # Set the agent to run on 32 | runs-on: ubuntu-latest 33 | 34 | ################## 35 | # Load all steps # 36 | ################## 37 | steps: 38 | ########################## 39 | # Checkout the code base # 40 | ########################## 41 | - name: Checkout Code 42 | uses: actions/checkout@v2 43 | with: 44 | # Full git history is needed to get a proper list of changed files within `super-linter` 45 | fetch-depth: 0 46 | 47 | ################################ 48 | # Run Linter against code base # 49 | ################################ 50 | - name: Lint Code Base 51 | uses: nvuillam/mega-linter@v5 52 | env: 53 | VALIDATE_ALL_CODEBASE: false 54 | DEFAULT_BRANCH: main 55 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 56 | DISABLE_LINTERS: SPELL_CSPELL,MARKDOWN_MARKDOWN_LINK_CHECK 57 | 58 | # Upload Mega-Linter artifacts. They will be available on Github action page "Artifacts" section 59 | - name: Archive production artifacts 60 | if: ${{ success() }} || ${{ failure() }} 61 | uses: actions/upload-artifact@v2 62 | with: 63 | name: Mega-Linter reports 64 | path: | 65 | report 66 | mega-linter.log 67 | -------------------------------------------------------------------------------- /bin/docker-runc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Run a new container by selecting the docker image from a interactive menu 4 | # 5 | # https://medium.com/@calbertts/docker-and-fuzzy-finder-fzf-4c6416f5e0b5 6 | 7 | set -o pipefail 8 | 9 | function fail() { 10 | printf '%s\n' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way. 11 | exit "${2-1}" ## Return a code specified by $2 or 1 by default. 12 | } 13 | 14 | function has() { 15 | # Check if a command is in $PATH 16 | which "$@" > /dev/null 2>&1 17 | } 18 | 19 | # shellcheck disable=SC2086,SC2162 20 | function runc() { 21 | export FZF_DEFAULT_OPTS='--height 90% --reverse --border' 22 | local image 23 | local cmd 24 | local volume 25 | local curDir 26 | image=$(docker images --format '{{.Repository}}:{{.Tag}}' | fzf-tmux --reverse --multi) 27 | if [[ $image != '' ]]; then 28 | echo -e "\n \033[1mDocker image:\033[0m" "$image" 29 | read -e -p $' \e[1mOptions: \e[0m' -i "-it --rm" options 30 | 31 | printf " \033[1mChoose the command: \033[0m" 32 | cmd=$(echo -e "/bin/bash\nsh" | fzf-tmux --reverse --multi) 33 | if [[ $cmd == '' ]]; then 34 | read -e -p $' \e[1mCustom command: \e[0m' cmd 35 | fi 36 | echo -e " \033[1mCommand: \033[0m" "$cmd" 37 | 38 | export FZF_DEFAULT_COMMAND='find ./ -type d -maxdepth 1 -exec basename {} \;' 39 | printf " \033[1mChoose the volume: \033[0m" 40 | volume=$(fzf-tmux --reverse --multi) 41 | curDir=${PWD##*/} 42 | if [[ $volume == '.' ]]; then 43 | echo -e " \033[1mVolume: \033[0m" "$volume" 44 | volume="$(pwd):/$curDir -w /$curDir" 45 | else 46 | echo -e " \033[1mVolume: \033[0m" "$volume" 47 | volume="$(pwd)/$volume:/$volume -w /$volume" 48 | fi 49 | 50 | export FZF_DEFAULT_COMMAND="" 51 | export FZF_DEFAULT_OPTS="" 52 | 53 | history -s runc 54 | history -s docker run $options -v $volume $image $cmd 55 | echo '' 56 | docker run $options -v $volume $image $cmd 57 | fi 58 | } 59 | 60 | if has fzf; then 61 | # shellcheck disable=SC2068 62 | runc $@ 63 | else 64 | fail "Cannot find 'fzf' in your PATH." 65 | fi 66 | -------------------------------------------------------------------------------- /docker-helpers.plugin.zsh: -------------------------------------------------------------------------------- 1 | # Copyright 2014-2022 Joseph Block 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | if (which docker &> /dev/null) 16 | then 17 | # Add our plugin's bin diretory to user's path 18 | PLUGIN_D="$(dirname $0)" 19 | export PATH=${PATH}:${PLUGIN_D}/bin 20 | 21 | alias d='docker' 22 | 23 | # Most of these aliases are from http://www.kartar.net/2014/03/some-useful-docker-bash-functions-and-aliases/ 24 | alias dkd='docker run -d -P' 25 | alias dki='docker run -t -i -P' 26 | alias dkl='docker ps -l -q' 27 | alias docker-daemonize='docker run -d -P' 28 | alias docker-interactive='docker run -t -i -P' 29 | alias docker-last='docker ps -l -q' 30 | alias dockerbuild='docker build' 31 | alias dockerimages='docker images' 32 | alias dockerps='docker ps' 33 | 34 | d-ip() { 35 | docker inspect --format "{{ .NetworkSettings.IPAddress }}" $1 36 | } 37 | 38 | dkb() { 39 | docker build -t="$1" . 40 | } 41 | 42 | d-grep() { 43 | docker ps | grep $@ | grep -v ^CONTAINER 44 | } 45 | 46 | d-kill-pattern() { 47 | docker ps \ 48 | | grep $@ \ 49 | | grep -v ^CONTAINER \ 50 | | awk '{print $1}' \ 51 | | xargs -rI % bash -c 'echo $(docker kill %; echo "killed!");' 52 | } 53 | 54 | d-pid() { 55 | docker inspect --format "{{ .State.Pid }}" $1 56 | } 57 | 58 | d-purge() { 59 | docker rm $(docker ps -a -q); 60 | } 61 | 62 | d-stats() { 63 | docker ps -q | xargs docker stats 64 | } 65 | 66 | d-stop() { 67 | # Stop all running containers 68 | docker stop $(docker ps -a -q); 69 | } 70 | 71 | d-zsh() { 72 | local TAG=$1 73 | docker run -v /tmp:/host_tmp:rw -i -t $TAG /bin/zsh 74 | } 75 | 76 | dps-monitor() { 77 | while true 78 | do 79 | clear 80 | docker ps | cut -c -$(tput cols) 81 | sleep 0.5 82 | done 83 | } 84 | 85 | # helpers for starting a container with access to the current directory 86 | 87 | d-alpine() { 88 | docker run -v $(pwd):/shared --rm -it alpine:latest /bin/sh 89 | } 90 | 91 | d-busybox() { 92 | docker run -v $(pwd):/shared --rm -it busybox:latest /bin/sh 93 | } 94 | 95 | d-debian() { 96 | docker run -v $(pwd):/shared --rm -it debian:latest /bin/bash 97 | } 98 | 99 | d-centos() { 100 | docker run -v $(pwd):/shared --rm -it centos:centos7 /bin/bash 101 | } 102 | 103 | d-centos6() { 104 | docker run -v $(pwd):/shared --rm -it centos:centos6 /bin/bash 105 | } 106 | 107 | d-fedora() { 108 | docker run -v $(pwd):/shared --rm -it fedora:20 /bin/bash 109 | } 110 | 111 | d-ubuntu() { 112 | docker run -v $(pwd):/shared --rm -it ubuntu:14.04 /bin/bash 113 | } 114 | 115 | fi 116 | 117 | if (which docker-compose &> /dev/null) 118 | then 119 | alias d-cp=docker-compose 120 | fi 121 | 122 | function docker-tags(){ 123 | curl -s -S "https://registry.hub.docker.com/v2/repositories/$@/tags/" | jq '."results"[]["name"]' |sort 124 | } 125 | -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | # Docker helper scripts 2 | 3 | [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 4 | ![Awesomebot](https://github.com/unixorn/docker-helpers.zshplugin/actions/workflows/awesomebot.yml/badge.svg) 5 | ![mega-linter](https://github.com/unixorn/docker-helpers.zshplugin/actions/workflows/mega-linter.yml/badge.svg) 6 | [![GitHub stars](https://img.shields.io/github/stars/unixorn/docker-helpers.zshplugin.svg)](https://github.com/unixorn/docker-helpers.zshplugin/stargazers) 7 | 8 | 9 | 10 | ## Table of Contents 11 | 12 | - [Script list](#script-list) 13 | - [Installing](#installing) 14 | - [Pre-Requisites](#pre-requisites) 15 | - [zgenom](#zgenom) 16 | - [Antigen](#antigen) 17 | - [Oh-My-Zsh](#oh-my-zsh) 18 | - [Other useful Docker stuff](#other-useful-docker-stuff) 19 | 20 | 21 | 22 | This is a collection of docker helper scripts, packaged as a ZSH plugin to make it easier to use with frameworks like [zgenom](https://github.com/jandamm/zgenom) and [antigen](https://github.com/zsh-users/antigen). 23 | 24 | Most of these were collected from blog posts, gists, slack - basically stuff I saw and thought was useful enough to stash away, and I've given credit where I know the source. 25 | 26 | If you wrote something I've collected and I didn't credit you, please create an issue or PR so I can correct it. 27 | 28 | ## Script list 29 | 30 | Command | Description | Credit 31 | ------- | ----------- | ------ 32 | | `boot2docker-timesync` | boot2docker drifts out of time sync every time my MacBook Pro sleeps. Run this to resync. | 33 | | `dive` | Wrapper script that calls wagoodman/dive to analyze a container image. | 34 | | `docker-check-for-image-update` | Check if a given image has been updated, and if so, run a command. | Matthias Lohr's [blog](https://mlohr.com/check-for-docker-image-updates/) | 35 | | `docker-container-volumes` | List the volumes attached to a container. | [http://www.tech-d.net/2014/05/05/docker-quicktip-5-backing-up-volumes/](http://www.tech-d.net/2014/05/05/docker-quicktip-5-backing-up-volumes/)) 36 | | `docker-create-backup-container` | Creates a container with all the volumes from all the containers on the host. | From [http://www.tech-d.net/2014/05/05/docker-quicktip-5-backing-up-volumes/](http://www.tech-d.net/2014/05/05/docker-quicktip-5-backing-up-volumes/) 37 | | `docker-delete-stopped-containers` | Cleans up stale stopped containers. | 38 | | `docker-here` | Builds an ephemeral container, runs it with the parameters you pass `docker-here`, then deletes the ephemeral container. | 39 | | `docker-ip` | Gets the pid of a running container. | 40 | | `docker-last` | Print the id of the last container you ran. | 41 | | `docker-lint` | Lint a Dockerfile with [hadolint](https://github.com/hadolint/hadolint). | 42 | | `docker-pid` | Print pid of a running container. | 43 | | `docker-ps-cleanup` | Cleans up `docker ps` output by deleting all exited containers. | 44 | | `docker-purge-unnamed-images` | Cleans up image cruft by deleting all the images that aren't named. | 45 | | `docker-remove-dangling-images` | Cleans up image cruft by deleting all dangling images. | 46 | | `docker-runc` | Uses [fzf](https://github.com/junegunn/fzf) to select an image and run a command in it. | 47 | | `docker-runinc` | Uses [fzf](https://github.com/junegunn/fzf) to select a running container and run a command inside it. | 48 | | `docker-shell` | Runs a shell inside a container with `pwd` mounted as `/pwd`. Defaults to bash inside debian:buster-slim, reads shell & image name from `STANDARD_DOCKER_COMMAND` and `STANDARD_DOCKER_IMAGE` or `$1` and `$2`. | 49 | | `docker-showipc` | Show the IP of a running docker container. | 50 | | `docker-stopc` | Stops and/or removes a docker container. | 51 | | `docker-superclean` | Clear out any stopped containers or stale images. | 52 | | `docker-update-all-images` | Update all images on the machine. | 53 | | `fzf-docker-attach` | Use [fzf](https://github.com/junegunn/fzf) to select a docker container to start and attach to | 54 | | `fzf-docker-rm` | Use [fzf](https://github.com/junegunn/fzf) to select a docker container to remove | 55 | | `fzf-docker-stop` | Use [fzf](https://github.com/junegunn/fzf) to select a docker container to stop | 56 | 57 | ## Installing 58 | 59 | ### Pre-Requisites 60 | 61 | No matter how you choose to install the plugin, it has the following pre-requisites: 62 | 63 | - `jq` - Install with `brew install jq` 64 | - `fzf` - Install with `brew install fzf` 65 | 66 | ### zgenom 67 | 68 | Add `zgenom load unixorn/docker-helpers.zshplugin` to your `.zshrc` wherever you're loading your other plugins. 69 | 70 | ### Antigen 71 | 72 | Add `antigen bundle unixorn/docker-helpers.zshplugin` to your `.zshrc` with your other plugins. You can test drive them without editing your .zshrc by running `antigen bundle unixorn/docker-helpers.zshplugin` in a running zsh session. 73 | 74 | ### Oh-My-Zsh 75 | 76 | 1. cd to your `oh-my-zsh` plugins directory (~/.oh-my-zsh/custom/plugins) 77 | 2. `git clone https://github.com/unixorn/docker-helpers.zshplugin docker-helpers` 78 | 3. Add docker-helpers to your plugins in your `.zshrc` 79 | ```zsh 80 | ... 81 | plugins=( ... docker-helpers ...) 82 | ... 83 | ``` 84 | 85 | ## Other useful Docker stuff 86 | 87 | * If you use [Sublime Text 2/3](http://sublimetext.com), check out [sublime-docker](https://github.com/dockerparis/sublime-docker). Lets you build inside Docker containers directly from [Sublime Text](http://sublimetext.com). 88 | * [dive](https://github.com/wagoodman/dive) - A tool for exploring a docker image, layer contents, and discovering ways to shrink your Docker image size. 89 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | --------------------------------------------------------------------------------