Skip to content

Instantly share code, notes, and snippets.

@ganta
Created May 18, 2022
Embed
What would you like to do?
Docker CLI Plugin for handling Intel version images

Installation

Put the script in ~/.docker/cli-plugin/docker-intel.

Usage

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment