Put the script in ~/.docker/cli-plugin/docker-intel.
docker intel COMMAND
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| function docker_cli_plugin_metadata() { | |
| local vendor="ganta" | |
| local version="1.0.0" | |
| local description="Handles Intel version images" | |
| local url="https://github.com/ganta" | |
| cat <<EOF | |
| { | |
| "SchemaVersion": "0.1.0", | |
| "Vendor": "${vendor}", | |
| "Version": "${version}", | |
| "ShortDescription": "${description}", | |
| "URL": "${url}", | |
| "Experimental": false | |
| } | |
| EOF | |
| } | |
| function usage() { | |
| cat <<EOF | |
| Usage: docker intel COMMAND | |
| Handles Intel version images | |
| Commands: | |
| build Build an image from a Dockerfile | |
| create Create a new container | |
| import Import the contents from a tarball to create a filesystem image | |
| pull Pull an image or a repository from a registry | |
| run Run a command in a new container | |
| Run 'docker intel COMMAND --help' for more information on a command. | |
| EOF | |
| } | |
| if [[ $1 == "docker-cli-plugin-metadata" ]] | |
| then | |
| docker_cli_plugin_metadata | |
| exit 0 | |
| fi | |
| shift | |
| command="$1" | |
| shift | |
| case "${command}" in | |
| build|create|import|pull|run) | |
| docker "${command}" --platform "linux/amd64" "$@" | |
| ;; | |
| help|--help|-h) | |
| usage | |
| ;; | |
| *) | |
| echo "${command} does not support --platform option" 1>&2 | |
| usage | |
| exit 1 | |
| ;; | |
| esac |