I saw this post about a custom cli app to make it just a little nicer to quickly shell in to a local docker container:
Docket : connect to your docker's container easily !
pob ・ Mar 5 ・ 2 min read
And I thought, what if instead of a brand new command, it was part of the docker cli? It's not well advertised, but you can! So I installed it as a custom docker command. Official docs here.
There are a couple rules.
Where does the script go? I wanted to run
docker goto
. The easiest choice for me was~/.docker/cli-plugins/docker-goto
. Whatever subcommand name you want, just prefix it with "docker-"-
You must have a subcommand called "docker-cli-plugin-metadata". When I run
docker goto docker-cli-plugin-metadata
, it has to output specific json. This block is enough:
if [[ "$1" == "docker-cli-plugin-metadata" ]]; then cat << HERE { "SchemaVersion": "0.1.0", "Vendor": "example.com", } HERE exit fi
Make it executable:
chmod +x ~/.docker/cli-plugins/docker-goto
Now you can make it do whatever you want! Full code in this gist.
Top comments (2)
The link to the official docs is broken.
😣 i guess they're getting rid of this? github.com/docker/cli/commit/459c6...