├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE │ └── pull_request_template.md └── workflows │ ├── lint.yml │ └── wospm.yml ├── .markdownlint.json ├── CODE_OF_CONDUCT ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── go.mod ├── go.sum ├── lib └── commands.go └── main.go /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | 7 | --- 8 | 9 | **Describe the bug** 10 | A clear and concise description of what the bug is. 11 | 12 | **To Reproduce** 13 | Steps to reproduce the behavior: 14 | 1. Go to '...' 15 | 2. Click on '....' 16 | 3. Scroll down to '....' 17 | 4. See error 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Screenshots** 23 | If applicable, add screenshots to help explain your problem. 24 | 25 | **Additional context** 26 | Add any other context about the problem here. 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: 'enhancement' 6 | 7 | --- 8 | 9 | **Is your feature request related to a problem? Please describe.** 10 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 11 | 12 | **Describe the solution you'd like** 13 | A clear and concise description of what you want to happen. 14 | 15 | **Describe alternatives you've considered** 16 | A clear and concise description of any alternative solutions or features you've considered. 17 | 18 | **Additional context** 19 | Add any other context or screenshots about the feature request here. 20 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/pull_request_template.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. 4 | 5 | Fixes #_issue-number_ 6 | 7 | ## Type of change 8 | 9 | Please select the type of change. 10 | 11 | - [ ] Bug fix (non-breaking change which fixes an issue) 12 | - [ ] New feature (non-breaking change which adds functionality) 13 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 14 | - [ ] Documentation update 15 | 16 | # How Can This Be Tested? 17 | 18 | Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration. 19 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint Actions 2 | on: [push] 3 | 4 | jobs: 5 | markdownlint: 6 | runs-on: ubuntu-latest 7 | name: Markdown Linter 8 | steps: 9 | - name: Checkout 10 | uses: actions/checkout@v2 11 | - name: markdownlint-cli 12 | uses: nosborn/github-action-markdown-cli@v1.1.1 13 | with: 14 | files: "README.md" 15 | -------------------------------------------------------------------------------- /.github/workflows/wospm.yml: -------------------------------------------------------------------------------- 1 | name: Checks For Open Source 2 | on: [push] 3 | 4 | jobs: 5 | wospm_checker: 6 | runs-on: ubuntu-latest 7 | name: WOSPM Checker 8 | steps: 9 | - name: Checkout 10 | uses: actions/checkout@v2 11 | - name: WOSPM Checker Github Action 12 | uses: WOSPM/wospm-checker-github-action@v1 13 | - name: Upload HTML Report When Success 14 | uses: actions/upload-artifact@v1 15 | with: 16 | name: HTML Report 17 | path: wospm.html 18 | - name: Upload HTML Report When Failed 19 | uses: actions/upload-artifact@v1 20 | if: failure() 21 | with: 22 | name: HTML Report 23 | path: wospm.html 24 | -------------------------------------------------------------------------------- /.markdownlint.json: -------------------------------------------------------------------------------- 1 | { 2 | "line-length": false, 3 | "no-inline-html": { 4 | "allowed_elements": [ 5 | "a", "img" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to make participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies within all project spaces, and it also applies when 49 | an individual is representing the project or its community in public spaces. 50 | Examples of representing a project or community include using an official 51 | project e-mail address, posting via an official social media account, or acting 52 | as an appointed representative at an online or offline event. Representation of 53 | a project may be further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at [INSERT EMAIL ADDRESS]. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html) 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq) 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | We accept contributions via Pull Requests on [Github](https://github.com/Trendyol/docker-shell/pulls). 6 | 7 | ## Pull Requests 8 | 9 | - **Sync** - Please make sure your forked repository is up to date with ours to avoid conflicts as much as possible. 10 | - **Language** - Please make sure to check your contribution for grammar mistakes and typos as much as possible. 11 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 12 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 13 | 14 | 15 | **Stay Secure**! 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Emre Savcı 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-shell 2 | 3 | A simple interactive prompt for Docker. Inspired from [kube-prompt](https://github.com/c-bata/kube-prompt) uses [go-prompt](https://github.com/c-bata/go-prompt). 4 | 5 | [![License: MIT](https://img.shields.io/badge/License-MIT-ligthgreen.svg)](https://opensource.org/licenses/MIT) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](CONTRIBUTING.md) 6 | 7 | 8 | 9 | ## Table Of Contents 10 | 11 | - [Features:](#features) 12 | - [Installation](#installation) 13 | - [Homebrew](#homebrew) 14 | - [Build From Source Code](#build-from-source-code) 15 | - [How To Use](#how-to-use) 16 | - [How To Contribute](#how-to-contribute) 17 | 18 | 19 | 20 | ## Features 21 | 22 | - [X] Suggest docker commands 23 | - [X] List container ids&names after docker exec/start/stop commands 24 | - [X] Suggest command parameters based on typed command 25 | - [X] List images from docker hub after docker pull command [v1.2.0](https://github.com/Trendyol/docker-shell/milestone/1) 26 | - [X] Suggest port mappings after docker run command [v1.3.0](https://github.com/Trendyol/docker-shell/milestone/2) 27 | - [X] Suggest available images after docker run command [v1.3.0](https://github.com/Trendyol/docker-shell/milestone/2) 28 | 29 | ## Installation 30 | 31 | ### Homebrew 32 | 33 | You can install by using *homebrew*: 34 | 35 | ```bash 36 | brew tap trendyol/trendyol-tap 37 | 38 | brew install docker-shell 39 | ``` 40 | 41 | ### Build From Source Code 42 | 43 | You can build the command from source code by following the steps below: 44 | 45 | ```bash 46 | git clone git@github.com:Trendyol/docker-shell.git 47 | 48 | cd docker-shell 49 | 50 | sudo go build -o /usr/local/bin/docker-shell . 51 | 52 | docker-shell 53 | ``` 54 | 55 | ## How To Use 56 | 57 | After installation, you can type `docker-shell` and run the interactive shell. 58 | 59 | [![asciicast](https://asciinema.org/a/AKDTBnD3gKKzACDdj7Tm670PJ.svg)](https://asciinema.org/a/AKDTBnD3gKKzACDdj7Tm670PJ) 60 | 61 | Image suggestion from docker hub: 62 | 63 | [![asciicast](https://asciinema.org/a/UCfYZNXCcVxIiqNKsAMtEhmiM.svg)](https://asciinema.org/a/UCfYZNXCcVxIiqNKsAMtEhmiM) 64 | 65 | Port mapping suggestion: 66 | 67 | [![asciicast](https://asciinema.org/a/7aWKWQJqqHZkpWZXwfy8AcrPj.svg)](https://asciinema.org/a/7aWKWQJqqHZkpWZXwfy8AcrPj) 68 | 69 | ## How To Contribute 70 | 71 | Contributions are **welcome** and will be fully **credited**. 72 | 73 | Please read the [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT) files for details. 74 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/mstrYoda/docker-shell 2 | 3 | replace github.com/mstrYoda/docker-shell/lib => ./lib 4 | 5 | go 1.13 6 | 7 | require ( 8 | docker.io/go-docker v1.0.0 9 | github.com/Microsoft/go-winio v0.4.14 // indirect 10 | github.com/c-bata/go-prompt v0.2.3 11 | github.com/docker/distribution v2.7.1+incompatible // indirect 12 | github.com/docker/go-connections v0.4.0 // indirect 13 | github.com/docker/go-units v0.4.0 // indirect 14 | github.com/gogo/protobuf v1.3.1 // indirect 15 | github.com/hashicorp/go-hclog v0.9.2 16 | github.com/hashicorp/go-retryablehttp v0.6.4 17 | github.com/mattn/go-runewidth v0.0.8 // indirect 18 | github.com/mattn/go-tty v0.0.3 // indirect 19 | github.com/opencontainers/go-digest v1.0.0-rc1 // indirect 20 | github.com/opencontainers/image-spec v1.0.1 // indirect 21 | github.com/patrickmn/go-cache v2.1.0+incompatible 22 | github.com/pkg/errors v0.9.1 // indirect 23 | github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942 // indirect 24 | golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa // indirect 25 | ) 26 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | docker.io/go-docker v1.0.0 h1:VdXS/aNYQxyA9wdLD5z8Q8Ro688/hG8HzKxYVEVbE6s= 2 | docker.io/go-docker v1.0.0/go.mod h1:7tiAn5a0LFmjbPDbyTPOaTTOuG1ZRNXdPA6RvKY+fpY= 3 | github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU= 4 | github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= 5 | github.com/c-bata/go-prompt v0.2.3 h1:jjCS+QhG/sULBhAaBdjb2PlMRVaKXQgn+4yzaauvs2s= 6 | github.com/c-bata/go-prompt v0.2.3/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= 7 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 8 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 9 | github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= 10 | github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= 11 | github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= 12 | github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= 13 | github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= 14 | github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= 15 | github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= 16 | github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= 17 | github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= 18 | github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= 19 | github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI= 20 | github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= 21 | github.com/hashicorp/go-retryablehttp v0.6.4 h1:BbgctKO892xEyOXnGiaAwIoSq1QZ/SS4AhjoAh9DnfY= 22 | github.com/hashicorp/go-retryablehttp v0.6.4/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= 23 | github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= 24 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 25 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 26 | github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= 27 | github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= 28 | github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 29 | github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= 30 | github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= 31 | github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= 32 | github.com/mattn/go-runewidth v0.0.8 h1:3tS41NlGYSmhhe/8fhGRzc+z3AYCw1Fe1WAyLuujKs0= 33 | github.com/mattn/go-runewidth v0.0.8/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= 34 | github.com/mattn/go-tty v0.0.3 h1:5OfyWorkyO7xP52Mq7tB36ajHDG5OHrmBGIS/DtakQI= 35 | github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0= 36 | github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= 37 | github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= 38 | github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= 39 | github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= 40 | github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= 41 | github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= 42 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 43 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 44 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 45 | github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942 h1:A7GG7zcGjl3jqAqGPmcNjd/D9hzL95SuoOQAaFNdLU0= 46 | github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ= 47 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 48 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 49 | github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= 50 | github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= 51 | github.com/smartystreets/gunit v0.0.0-20190426220047-d9c9211acd48/go.mod h1:oqKsUQaUkJ2EU1ZzLQFJt1WUp9DDuj1CnZbp4DwPwL4= 52 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 53 | github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= 54 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 55 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 56 | golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa h1:F+8P+gmewFQYRk6JoLQLwjBCTu3mcIURZfNkVweuRKA= 57 | golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 58 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 59 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= 60 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 61 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 62 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 63 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 64 | golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 65 | golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 66 | golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= 67 | golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 68 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 69 | golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 70 | -------------------------------------------------------------------------------- /lib/commands.go: -------------------------------------------------------------------------------- 1 | package commands 2 | 3 | import ( 4 | "github.com/c-bata/go-prompt" 5 | ) 6 | 7 | type Commands struct { 8 | DockerSuggestions []prompt.Suggest 9 | DockerSubSuggestions map[string][]prompt.Suggest 10 | } 11 | 12 | func New() Commands { 13 | return Commands{ 14 | DockerSuggestions: []prompt.Suggest{ 15 | {Text: "attach", Description: "Attach local standard input, output, and error streams to a running container"}, 16 | {Text: "build", Description: "Build an image from a Dockerfile"}, 17 | {Text: "builder", Description: "Manage builds"}, 18 | {Text: "checkpoint", Description: "Manage checkpoints"}, 19 | {Text: "commit", Description: "Create a new image from a container’s changes"}, 20 | {Text: "config", Description: "Manage Docker configs"}, 21 | {Text: "container", Description: "Manage containers"}, 22 | {Text: "context", Description: "Manage contexts"}, 23 | {Text: "cp", Description: "Copy files/folders between a container and the local filesystem"}, 24 | {Text: "create", Description: "Create a new container"}, 25 | {Text: "diff", Description: "Inspect changes to files or directories on a container’s filesystem"}, 26 | {Text: "events", Description: "Get real time events from the server"}, 27 | {Text: "exec", Description: "Run a command in a running container"}, 28 | {Text: "export", Description: "Export a container’s filesystem as a tar archive"}, 29 | {Text: "history", Description: "Show the history of an image"}, 30 | {Text: "image", Description: "Manage images"}, 31 | {Text: "images", Description: "List images"}, 32 | {Text: "import", Description: "Import the contents from a tarball to create a filesystem image"}, 33 | {Text: "info", Description: "Display system-wide information"}, 34 | {Text: "inspect", Description: "Return low-level information on Docker objects"}, 35 | {Text: "kill", Description: "Kill one or more running containers"}, 36 | {Text: "load", Description: "Load an image from a tar archive or STDIN"}, 37 | {Text: "login", Description: "Log in to a Docker registry"}, 38 | {Text: "logout", Description: "Log out from a Docker registry"}, 39 | {Text: "logs", Description: "Fetch the logs of a container"}, 40 | {Text: "manifest", Description: "Manage Docker image manifests and manifest lists"}, 41 | {Text: "network", Description: "Manage networks"}, 42 | {Text: "node", Description: "Manage Swarm nodes"}, 43 | {Text: "pause", Description: "Pause all processes within one or more containers"}, 44 | {Text: "plugin", Description: "Manage plugins"}, 45 | {Text: "port", Description: "List port mappings or a specific mapping for the container"}, 46 | {Text: "ps", Description: "List containers"}, 47 | {Text: "pull", Description: "Pull an image or a repository from a registry"}, 48 | {Text: "push", Description: "Push an image or a repository to a registry"}, 49 | {Text: "rename", Description: "Rename a container"}, 50 | {Text: "restart", Description: "Restart one or more containers"}, 51 | {Text: "rm", Description: "Remove one or more containers"}, 52 | {Text: "rmi", Description: "Remove one or more images"}, 53 | {Text: "run", Description: "Run a command in a new container"}, 54 | {Text: "save", Description: "Save one or more images to a tar archive (streamed to STDOUT by default)"}, 55 | {Text: "search", Description: "Search the Docker Hub for images"}, 56 | {Text: "secret", Description: "Manage Docker secrets"}, 57 | {Text: "service", Description: "Manage services"}, 58 | {Text: "stack", Description: "Manage Docker stacks"}, 59 | {Text: "start", Description: "Start one or more stopped containers"}, 60 | {Text: "stats", Description: "Display a live stream of container(s) resource usage statistics"}, 61 | {Text: "stop", Description: "Stop one or more running containers"}, 62 | {Text: "swarm", Description: "Manage Swarm"}, 63 | {Text: "system", Description: "Manage Docker"}, 64 | {Text: "tag", Description: "Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE"}, 65 | {Text: "top", Description: "Display the running processes of a container"}, 66 | {Text: "trust", Description: "Manage trust on Docker images"}, 67 | {Text: "unpause", Description: "Unpause all processes within one or more containers"}, 68 | {Text: "update", Description: "Update configuration of one or more containers"}, 69 | {Text: "version", Description: "Show the Docker version information"}, 70 | {Text: "volume", Description: "Manage volumes"}, 71 | {Text: "wait", Description: "Block until one or more containers stop, then print their exit codes"}, 72 | {Text: "exit", Description: "Exit command prompt"}, 73 | }, 74 | DockerSubSuggestions: map[string][]prompt.Suggest{ 75 | "attach": { 76 | prompt.Suggest{Text: "--detach-keys", Description: "Override the key sequence for detaching a container"}, 77 | prompt.Suggest{Text: "--no-stdin", Description: "Do not attach STDIN"}, 78 | prompt.Suggest{Text: "--sig-proxy", Description: "Proxy all received signals to the process"}, 79 | }, 80 | "build": { 81 | prompt.Suggest{Text: "--add-host", Description: "Add a custom host-to-IP mapping (host:ip)"}, 82 | prompt.Suggest{Text: "--build-arg", Description: "Set build-time variables"}, 83 | prompt.Suggest{Text: "--cache-from", Description: "Images to consider as cache sources"}, 84 | prompt.Suggest{Text: "--cgroup-parent", Description: "Optional parent cgroup for the container"}, 85 | prompt.Suggest{Text: "--compress", Description: "Compress the build context using gzip"}, 86 | prompt.Suggest{Text: "--cpu-period", Description: "Limit the CPU CFS (Completely Fair Scheduler) period"}, 87 | prompt.Suggest{Text: "--cpu-quota", Description: "Limit the CPU CFS (Completely Fair Scheduler) quota"}, 88 | prompt.Suggest{Text: "--cpu-shares", Description: "CPU shares (relative weight)"}, 89 | prompt.Suggest{Text: "--cpuset-cpus", Description: "CPUs in which to allow execution (0-3, 0,1)"}, 90 | prompt.Suggest{Text: "--cpuset-mems", Description: "MEMs in which to allow execution (0-3, 0,1)"}, 91 | prompt.Suggest{Text: "--disable-content-trust", Description: "Skip image verification"}, 92 | prompt.Suggest{Text: "--file", Description: "Name of the Dockerfile (Default is ‘PATH/Dockerfile’)"}, 93 | prompt.Suggest{Text: "--force-rm", Description: "Always remove intermediate containers"}, 94 | prompt.Suggest{Text: "--iidfile", Description: "Write the image ID to the file"}, 95 | prompt.Suggest{Text: "--isolation", Description: "Container isolation technology"}, 96 | prompt.Suggest{Text: "--label", Description: "Set metadata for an image"}, 97 | prompt.Suggest{Text: "--memory", Description: "Memory limit"}, 98 | prompt.Suggest{Text: "--memory-swap", Description: "Swap limit equal to memory plus swap: ‘-1’ to enable unlimited swap"}, 99 | prompt.Suggest{Text: "--network", Description: ""}, 100 | prompt.Suggest{Text: "--no-cache", Description: "Do not use cache when building the image"}, 101 | prompt.Suggest{Text: "--output", Description: ""}, 102 | prompt.Suggest{Text: "--platform", Description: ""}, 103 | prompt.Suggest{Text: "--progress", Description: "Set type of progress output (auto, plain, tty). Use plain to show container output"}, 104 | prompt.Suggest{Text: "--pull", Description: "Always attempt to pull a newer version of the image"}, 105 | prompt.Suggest{Text: "--quiet", Description: "Suppress the build output and print image ID on success"}, 106 | prompt.Suggest{Text: "--rm", Description: "Remove intermediate containers after a successful build"}, 107 | prompt.Suggest{Text: "--secret", Description: ""}, 108 | prompt.Suggest{Text: "--security-opt", Description: "Security options"}, 109 | prompt.Suggest{Text: "--shm-size", Description: "Size of /dev/shm"}, 110 | prompt.Suggest{Text: "--squash", Description: ""}, 111 | prompt.Suggest{Text: "--ssh", Description: ""}, 112 | prompt.Suggest{Text: "--stream", Description: ""}, 113 | prompt.Suggest{Text: "--tag", Description: "Name and optionally a tag in the ‘name:tag’ format"}, 114 | prompt.Suggest{Text: "--target", Description: "Set the target build stage to build."}, 115 | prompt.Suggest{Text: "--ulimit", Description: "Ulimit options"}, 116 | }, 117 | "commit": { 118 | prompt.Suggest{Text: "--author", Description: "Author (e.g., “John Hannibal Smith "}, 119 | prompt.Suggest{Text: "--change", Description: "Apply Dockerfile instruction to the created image"}, 120 | prompt.Suggest{Text: "--message", Description: "Commit message"}, 121 | prompt.Suggest{Text: "--pause", Description: "Pause container during commit"}, 122 | }, 123 | "cp": { 124 | prompt.Suggest{Text: "--archive", Description: "Archive mode (copy all uid/gid information)"}, 125 | prompt.Suggest{Text: "--follow-link", Description: "Always follow symbol link in SRC_PATH"}, 126 | }, 127 | "create": { 128 | prompt.Suggest{Text: "--add-host", Description: "Add a custom host-to-IP mapping (host:ip)"}, 129 | prompt.Suggest{Text: "--attach", Description: "Attach to STDIN, STDOUT or STDERR"}, 130 | prompt.Suggest{Text: "--blkio-weight", Description: "Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)"}, 131 | prompt.Suggest{Text: "--blkio-weight-device", Description: "Block IO weight (relative device weight)"}, 132 | prompt.Suggest{Text: "--cap-add", Description: "Add Linux capabilities"}, 133 | prompt.Suggest{Text: "--cap-drop", Description: "Drop Linux capabilities"}, 134 | prompt.Suggest{Text: "--cgroup-parent", Description: "Optional parent cgroup for the container"}, 135 | prompt.Suggest{Text: "--cidfile", Description: "Write the container ID to the file"}, 136 | prompt.Suggest{Text: "--cpu-count", Description: "CPU count (Windows only)"}, 137 | prompt.Suggest{Text: "--cpu-percent", Description: "CPU percent (Windows only)"}, 138 | prompt.Suggest{Text: "--cpu-period", Description: "Limit CPU CFS (Completely Fair Scheduler) period"}, 139 | prompt.Suggest{Text: "--cpu-quota", Description: "Limit CPU CFS (Completely Fair Scheduler) quota"}, 140 | prompt.Suggest{Text: "--cpu-rt-period", Description: ""}, 141 | prompt.Suggest{Text: "--cpu-rt-runtime", Description: ""}, 142 | prompt.Suggest{Text: "--cpu-shares", Description: "CPU shares (relative weight)"}, 143 | prompt.Suggest{Text: "--cpus", Description: ""}, 144 | prompt.Suggest{Text: "--cpuset-cpus", Description: "CPUs in which to allow execution (0-3, 0,1)"}, 145 | prompt.Suggest{Text: "--cpuset-mems", Description: "MEMs in which to allow execution (0-3, 0,1)"}, 146 | prompt.Suggest{Text: "--device", Description: "Add a host device to the container"}, 147 | prompt.Suggest{Text: "--device-cgroup-rule", Description: "Add a rule to the cgroup allowed devices list"}, 148 | prompt.Suggest{Text: "--device-read-bps", Description: "Limit read rate (bytes per second) from a device"}, 149 | prompt.Suggest{Text: "--device-read-iops", Description: "Limit read rate (IO per second) from a device"}, 150 | prompt.Suggest{Text: "--device-write-bps", Description: "Limit write rate (bytes per second) to a device"}, 151 | prompt.Suggest{Text: "--device-write-iops", Description: "Limit write rate (IO per second) to a device"}, 152 | prompt.Suggest{Text: "--disable-content-trust", Description: "Skip image verification"}, 153 | prompt.Suggest{Text: "--dns", Description: "Set custom DNS servers"}, 154 | prompt.Suggest{Text: "--dns-opt", Description: "Set DNS options"}, 155 | prompt.Suggest{Text: "--dns-option", Description: "Set DNS options"}, 156 | prompt.Suggest{Text: "--dns-search", Description: "Set custom DNS search domains"}, 157 | prompt.Suggest{Text: "--domainname", Description: "Container NIS domain name"}, 158 | prompt.Suggest{Text: "--entrypoint", Description: "Overwrite the default ENTRYPOINT of the image"}, 159 | prompt.Suggest{Text: "--env", Description: "Set environment variables"}, 160 | prompt.Suggest{Text: "--env-file", Description: "Read in a file of environment variables"}, 161 | prompt.Suggest{Text: "--expose", Description: "Expose a port or a range of ports"}, 162 | prompt.Suggest{Text: "--gpus", Description: ""}, 163 | prompt.Suggest{Text: "--group-add", Description: "Add additional groups to join"}, 164 | prompt.Suggest{Text: "--health-cmd", Description: "Command to run to check health"}, 165 | prompt.Suggest{Text: "--health-interval", Description: "Time between running the check (ms|s|m|h) (default 0s)"}, 166 | prompt.Suggest{Text: "--health-retries", Description: "Consecutive failures needed to report unhealthy"}, 167 | prompt.Suggest{Text: "--health-start-period", Description: ""}, 168 | prompt.Suggest{Text: "--health-timeout", Description: "Maximum time to allow one check to run (ms|s|m|h) (default 0s)"}, 169 | prompt.Suggest{Text: "--help", Description: "Print usage"}, 170 | prompt.Suggest{Text: "--hostname", Description: "Container host name"}, 171 | prompt.Suggest{Text: "--init", Description: ""}, 172 | prompt.Suggest{Text: "--interactive", Description: "Keep STDIN open even if not attached"}, 173 | prompt.Suggest{Text: "--io-maxbandwidth", Description: "Maximum IO bandwidth limit for the system drive (Windows only)"}, 174 | prompt.Suggest{Text: "--io-maxiops", Description: "Maximum IOps limit for the system drive (Windows only)"}, 175 | prompt.Suggest{Text: "--ip", Description: "IPv4 address (e.g., 172.30.100.104)"}, 176 | prompt.Suggest{Text: "--ip6", Description: "IPv6 address (e.g., 2001:db8::33)"}, 177 | prompt.Suggest{Text: "--ipc", Description: "IPC mode to use"}, 178 | prompt.Suggest{Text: "--isolation", Description: "Container isolation technology"}, 179 | prompt.Suggest{Text: "--kernel-memory", Description: "Kernel memory limit"}, 180 | prompt.Suggest{Text: "--label", Description: "Set meta data on a container"}, 181 | prompt.Suggest{Text: "--label-file", Description: "Read in a line delimited file of labels"}, 182 | prompt.Suggest{Text: "--link", Description: "Add link to another container"}, 183 | prompt.Suggest{Text: "--link-local-ip", Description: "Container IPv4/IPv6 link-local addresses"}, 184 | prompt.Suggest{Text: "--log-driver", Description: "Logging driver for the container"}, 185 | prompt.Suggest{Text: "--log-opt", Description: "Log driver options"}, 186 | prompt.Suggest{Text: "--mac-address", Description: "Container MAC address (e.g., 92:d0:c6:0a:29:33)"}, 187 | prompt.Suggest{Text: "--memory", Description: "Memory limit"}, 188 | prompt.Suggest{Text: "--memory-reservation", Description: "Memory soft limit"}, 189 | prompt.Suggest{Text: "--memory-swap", Description: "Swap limit equal to memory plus swap: ‘-1’ to enable unlimited swap"}, 190 | prompt.Suggest{Text: "--memory-swappiness", Description: "Tune container memory swappiness (0 to 100)"}, 191 | prompt.Suggest{Text: "--mount", Description: "Attach a filesystem mount to the container"}, 192 | prompt.Suggest{Text: "--name", Description: "Assign a name to the container"}, 193 | prompt.Suggest{Text: "--net", Description: "Connect a container to a network"}, 194 | prompt.Suggest{Text: "--net-alias", Description: "Add network-scoped alias for the container"}, 195 | prompt.Suggest{Text: "--network", Description: "Connect a container to a network"}, 196 | prompt.Suggest{Text: "--network-alias", Description: "Add network-scoped alias for the container"}, 197 | prompt.Suggest{Text: "--no-healthcheck", Description: "Disable any container-specified HEALTHCHECK"}, 198 | prompt.Suggest{Text: "--oom-kill-disable", Description: "Disable OOM Killer"}, 199 | prompt.Suggest{Text: "--oom-score-adj", Description: "Tune host’s OOM preferences (-1000 to 1000)"}, 200 | prompt.Suggest{Text: "--pid", Description: "PID namespace to use"}, 201 | prompt.Suggest{Text: "--pids-limit", Description: "Tune container pids limit (set -1 for unlimited)"}, 202 | prompt.Suggest{Text: "--platform", Description: ""}, 203 | prompt.Suggest{Text: "--privileged", Description: "Give extended privileges to this container"}, 204 | prompt.Suggest{Text: "--publish", Description: "Publish a container’s port(s) to the host"}, 205 | prompt.Suggest{Text: "--publish-all", Description: "Publish all exposed ports to random ports"}, 206 | prompt.Suggest{Text: "--read-only", Description: "Mount the container’s root filesystem as read only"}, 207 | prompt.Suggest{Text: "--restart", Description: "Restart policy to apply when a container exits"}, 208 | prompt.Suggest{Text: "--rm", Description: "Automatically remove the container when it exits"}, 209 | prompt.Suggest{Text: "--runtime", Description: "Runtime to use for this container"}, 210 | prompt.Suggest{Text: "--security-opt", Description: "Security Options"}, 211 | prompt.Suggest{Text: "--shm-size", Description: "Size of /dev/shm"}, 212 | prompt.Suggest{Text: "--stop-signal", Description: "Signal to stop a container"}, 213 | prompt.Suggest{Text: "--stop-timeout", Description: ""}, 214 | prompt.Suggest{Text: "--storage-opt", Description: "Storage driver options for the container"}, 215 | prompt.Suggest{Text: "--sysctl", Description: "Sysctl options"}, 216 | prompt.Suggest{Text: "--tmpfs", Description: "Mount a tmpfs directory"}, 217 | prompt.Suggest{Text: "--tty", Description: "Allocate a pseudo-TTY"}, 218 | prompt.Suggest{Text: "--ulimit", Description: "Ulimit options"}, 219 | prompt.Suggest{Text: "--user", Description: "Username or UID (format: <name|uid>[:<group|gid>])"}, 220 | prompt.Suggest{Text: "--userns", Description: "User namespace to use"}, 221 | prompt.Suggest{Text: "--uts", Description: "UTS namespace to use"}, 222 | prompt.Suggest{Text: "--volume", Description: "Bind mount a volume"}, 223 | prompt.Suggest{Text: "--volume-driver", Description: "Optional volume driver for the container"}, 224 | prompt.Suggest{Text: "--volumes-from", Description: "Mount volumes from the specified container(s)"}, 225 | prompt.Suggest{Text: "--workdir", Description: "Working directory inside the container"}, 226 | }, 227 | "events": { 228 | prompt.Suggest{Text: "--filter", Description: "Filter output based on conditions provided"}, 229 | prompt.Suggest{Text: "--format", Description: "Format the output using the given Go template"}, 230 | prompt.Suggest{Text: "--since", Description: "Show all events created since timestamp"}, 231 | prompt.Suggest{Text: "--until", Description: "Stream events until this timestamp"}, 232 | }, 233 | "exec": { 234 | prompt.Suggest{Text: "--detach", Description: "Detached mode: run command in the background"}, 235 | prompt.Suggest{Text: "--detach-keys", Description: "Override the key sequence for detaching a container"}, 236 | prompt.Suggest{Text: "--env", Description: ""}, 237 | prompt.Suggest{Text: "--interactive", Description: "Keep STDIN open even if not attached"}, 238 | prompt.Suggest{Text: "--privileged", Description: "Give extended privileges to the command"}, 239 | prompt.Suggest{Text: "--tty", Description: "Allocate a pseudo-TTY"}, 240 | prompt.Suggest{Text: "--user", Description: "Username or UID (format: <name|uid>[:<group|gid>])"}, 241 | prompt.Suggest{Text: "--workdir", Description: ""}, 242 | }, 243 | "export": { 244 | prompt.Suggest{Text: "--output", Description: "Write to a file, instead of STDOUT"}, 245 | }, 246 | "history": { 247 | prompt.Suggest{Text: "--format", Description: "Pretty-print images using a Go template"}, 248 | prompt.Suggest{Text: "--human", Description: "Print sizes and dates in human readable format"}, 249 | prompt.Suggest{Text: "--no-trunc", Description: "Don’t truncate output"}, 250 | prompt.Suggest{Text: "--quiet", Description: "Only show numeric IDs"}, 251 | }, 252 | "images": { 253 | prompt.Suggest{Text: "--all", Description: "Show all images (default hides intermediate images)"}, 254 | prompt.Suggest{Text: "--digests", Description: "Show digests"}, 255 | prompt.Suggest{Text: "--filter", Description: "Filter output based on conditions provided"}, 256 | prompt.Suggest{Text: "--format", Description: "Pretty-print images using a Go template"}, 257 | prompt.Suggest{Text: "--no-trunc", Description: "Don’t truncate output"}, 258 | prompt.Suggest{Text: "--quiet", Description: "Only show numeric IDs"}, 259 | }, 260 | "import": { 261 | prompt.Suggest{Text: "--change", Description: "Apply Dockerfile instruction to the created image"}, 262 | prompt.Suggest{Text: "--message", Description: "Set commit message for imported image"}, 263 | prompt.Suggest{Text: "--platform", Description: ""}, 264 | }, 265 | "info": { 266 | prompt.Suggest{Text: "--format", Description: "Format the output using the given Go template"}, 267 | }, 268 | "inspect": { 269 | prompt.Suggest{Text: "--format", Description: "Format the output using the given Go template"}, 270 | prompt.Suggest{Text: "--size", Description: "Display total file sizes if the type is container"}, 271 | prompt.Suggest{Text: "--type", Description: "Return JSON for specified type"}, 272 | }, 273 | "kill": { 274 | prompt.Suggest{Text: "--signal", Description: "Signal to send to the container"}, 275 | }, 276 | "load": { 277 | prompt.Suggest{Text: "--input", Description: "Read from tar archive file, instead of STDIN"}, 278 | prompt.Suggest{Text: "--quiet", Description: "Suppress the load output"}, 279 | }, 280 | "login": { 281 | prompt.Suggest{Text: "--password", Description: "Password"}, 282 | prompt.Suggest{Text: "--password-stdin", Description: "Take the password from stdin"}, 283 | prompt.Suggest{Text: "--username", Description: "Username"}, 284 | }, 285 | "logs": { 286 | prompt.Suggest{Text: "--details", Description: "Show extra details provided to logs"}, 287 | prompt.Suggest{Text: "--follow", Description: "Follow log output"}, 288 | prompt.Suggest{Text: "--since", Description: "Show logs since timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)"}, 289 | prompt.Suggest{Text: "--tail", Description: "Number of lines to show from the end of the logs"}, 290 | prompt.Suggest{Text: "--timestamps", Description: "Show timestamps"}, 291 | prompt.Suggest{Text: "--until", Description: ""}, 292 | }, 293 | "ps": { 294 | prompt.Suggest{Text: "--all", Description: "Show all containers (default shows just running)"}, 295 | prompt.Suggest{Text: "--filter", Description: "Filter output based on conditions provided"}, 296 | prompt.Suggest{Text: "--format", Description: "Pretty-print containers using a Go template"}, 297 | prompt.Suggest{Text: "--last", Description: "Show n last created containers (includes all states)"}, 298 | prompt.Suggest{Text: "--latest", Description: "Show the latest created container (includes all states)"}, 299 | prompt.Suggest{Text: "--no-trunc", Description: "Don’t truncate output"}, 300 | prompt.Suggest{Text: "--quiet", Description: "Only display numeric IDs"}, 301 | prompt.Suggest{Text: "--size", Description: "Display total file sizes"}, 302 | }, 303 | "pull": { 304 | prompt.Suggest{Text: "--all-tags", Description: "Download all tagged images in the repository"}, 305 | prompt.Suggest{Text: "--disable-content-trust", Description: "Skip image verification"}, 306 | prompt.Suggest{Text: "--platform", Description: ""}, 307 | prompt.Suggest{Text: "--quiet", Description: "Suppress verbose output"}, 308 | }, 309 | "push": { 310 | prompt.Suggest{Text: "--disable-content-trust", Description: "Skip image signing"}, 311 | }, 312 | "restart": { 313 | prompt.Suggest{Text: "--time", Description: "Seconds to wait for stop before killing the container"}, 314 | }, 315 | "rm": { 316 | prompt.Suggest{Text: "--force", Description: "Force the removal of a running container (uses SIGKILL)"}, 317 | prompt.Suggest{Text: "--link", Description: "Remove the specified link"}, 318 | prompt.Suggest{Text: "--volumes", Description: "Remove the volumes associated with the container"}, 319 | }, 320 | "rmi": { 321 | prompt.Suggest{Text: "--force", Description: "Force removal of the image"}, 322 | prompt.Suggest{Text: "--no-prune", Description: "Do not delete untagged parents"}, 323 | }, 324 | "run": { 325 | prompt.Suggest{Text: "--add-host", Description: "Add a custom host-to-IP mapping (host:ip)"}, 326 | prompt.Suggest{Text: "--attach", Description: "Attach to STDIN, STDOUT or STDERR"}, 327 | prompt.Suggest{Text: "--blkio-weight", Description: "Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)"}, 328 | prompt.Suggest{Text: "--blkio-weight-device", Description: "Block IO weight (relative device weight)"}, 329 | prompt.Suggest{Text: "--cap-add", Description: "Add Linux capabilities"}, 330 | prompt.Suggest{Text: "--cap-drop", Description: "Drop Linux capabilities"}, 331 | prompt.Suggest{Text: "--cgroup-parent", Description: "Optional parent cgroup for the container"}, 332 | prompt.Suggest{Text: "--cidfile", Description: "Write the container ID to the file"}, 333 | prompt.Suggest{Text: "--cpu-count", Description: "CPU count (Windows only)"}, 334 | prompt.Suggest{Text: "--cpu-percent", Description: "CPU percent (Windows only)"}, 335 | prompt.Suggest{Text: "--cpu-period", Description: "Limit CPU CFS (Completely Fair Scheduler) period"}, 336 | prompt.Suggest{Text: "--cpu-quota", Description: "Limit CPU CFS (Completely Fair Scheduler) quota"}, 337 | prompt.Suggest{Text: "--cpu-rt-period", Description: ""}, 338 | prompt.Suggest{Text: "--cpu-rt-runtime", Description: ""}, 339 | prompt.Suggest{Text: "--cpu-shares", Description: "CPU shares (relative weight)"}, 340 | prompt.Suggest{Text: "--cpus", Description: ""}, 341 | prompt.Suggest{Text: "--cpuset-cpus", Description: "CPUs in which to allow execution (0-3, 0,1)"}, 342 | prompt.Suggest{Text: "--cpuset-mems", Description: "MEMs in which to allow execution (0-3, 0,1)"}, 343 | prompt.Suggest{Text: "--detach", Description: "Run container in background and print container ID"}, 344 | prompt.Suggest{Text: "--detach-keys", Description: "Override the key sequence for detaching a container"}, 345 | prompt.Suggest{Text: "--device", Description: "Add a host device to the container"}, 346 | prompt.Suggest{Text: "--device-cgroup-rule", Description: "Add a rule to the cgroup allowed devices list"}, 347 | prompt.Suggest{Text: "--device-read-bps", Description: "Limit read rate (bytes per second) from a device"}, 348 | prompt.Suggest{Text: "--device-read-iops", Description: "Limit read rate (IO per second) from a device"}, 349 | prompt.Suggest{Text: "--device-write-bps", Description: "Limit write rate (bytes per second) to a device"}, 350 | prompt.Suggest{Text: "--device-write-iops", Description: "Limit write rate (IO per second) to a device"}, 351 | prompt.Suggest{Text: "--disable-content-trust", Description: "Skip image verification"}, 352 | prompt.Suggest{Text: "--dns", Description: "Set custom DNS servers"}, 353 | prompt.Suggest{Text: "--dns-opt", Description: "Set DNS options"}, 354 | prompt.Suggest{Text: "--dns-option", Description: "Set DNS options"}, 355 | prompt.Suggest{Text: "--dns-search", Description: "Set custom DNS search domains"}, 356 | prompt.Suggest{Text: "--domainname", Description: "Container NIS domain name"}, 357 | prompt.Suggest{Text: "--entrypoint", Description: "Overwrite the default ENTRYPOINT of the image"}, 358 | prompt.Suggest{Text: "--env", Description: "Set environment variables"}, 359 | prompt.Suggest{Text: "--env-file", Description: "Read in a file of environment variables"}, 360 | prompt.Suggest{Text: "--expose", Description: "Expose a port or a range of ports"}, 361 | prompt.Suggest{Text: "--gpus", Description: ""}, 362 | prompt.Suggest{Text: "--group-add", Description: "Add additional groups to join"}, 363 | prompt.Suggest{Text: "--health-cmd", Description: "Command to run to check health"}, 364 | prompt.Suggest{Text: "--health-interval", Description: "Time between running the check (ms|s|m|h) (default 0s)"}, 365 | prompt.Suggest{Text: "--health-retries", Description: "Consecutive failures needed to report unhealthy"}, 366 | prompt.Suggest{Text: "--health-start-period", Description: ""}, 367 | prompt.Suggest{Text: "--health-timeout", Description: "Maximum time to allow one check to run (ms|s|m|h) (default 0s)"}, 368 | prompt.Suggest{Text: "--help", Description: "Print usage"}, 369 | prompt.Suggest{Text: "--hostname", Description: "Container host name"}, 370 | prompt.Suggest{Text: "--init", Description: ""}, 371 | prompt.Suggest{Text: "--interactive", Description: "Keep STDIN open even if not attached"}, 372 | prompt.Suggest{Text: "--io-maxbandwidth", Description: "Maximum IO bandwidth limit for the system drive (Windows only)"}, 373 | prompt.Suggest{Text: "--io-maxiops", Description: "Maximum IOps limit for the system drive (Windows only)"}, 374 | prompt.Suggest{Text: "--ip", Description: "IPv4 address (e.g., 172.30.100.104)"}, 375 | prompt.Suggest{Text: "--ip6", Description: "IPv6 address (e.g., 2001:db8::33)"}, 376 | prompt.Suggest{Text: "--ipc", Description: "IPC mode to use"}, 377 | prompt.Suggest{Text: "--isolation", Description: "Container isolation technology"}, 378 | prompt.Suggest{Text: "--kernel-memory", Description: "Kernel memory limit"}, 379 | prompt.Suggest{Text: "--label", Description: "Set meta data on a container"}, 380 | prompt.Suggest{Text: "--label-file", Description: "Read in a line delimited file of labels"}, 381 | prompt.Suggest{Text: "--link", Description: "Add link to another container"}, 382 | prompt.Suggest{Text: "--link-local-ip", Description: "Container IPv4/IPv6 link-local addresses"}, 383 | prompt.Suggest{Text: "--log-driver", Description: "Logging driver for the container"}, 384 | prompt.Suggest{Text: "--log-opt", Description: "Log driver options"}, 385 | prompt.Suggest{Text: "--mac-address", Description: "Container MAC address (e.g., 92:d0:c6:0a:29:33)"}, 386 | prompt.Suggest{Text: "--memory", Description: "Memory limit"}, 387 | prompt.Suggest{Text: "--memory-reservation", Description: "Memory soft limit"}, 388 | prompt.Suggest{Text: "--memory-swap", Description: "Swap limit equal to memory plus swap: ‘-1’ to enable unlimited swap"}, 389 | prompt.Suggest{Text: "--memory-swappiness", Description: "Tune container memory swappiness (0 to 100)"}, 390 | prompt.Suggest{Text: "--mount", Description: "Attach a filesystem mount to the container"}, 391 | prompt.Suggest{Text: "--name", Description: "Assign a name to the container"}, 392 | prompt.Suggest{Text: "--net", Description: "Connect a container to a network"}, 393 | prompt.Suggest{Text: "--net-alias", Description: "Add network-scoped alias for the container"}, 394 | prompt.Suggest{Text: "--network", Description: "Connect a container to a network"}, 395 | prompt.Suggest{Text: "--network-alias", Description: "Add network-scoped alias for the container"}, 396 | prompt.Suggest{Text: "--no-healthcheck", Description: "Disable any container-specified HEALTHCHECK"}, 397 | prompt.Suggest{Text: "--oom-kill-disable", Description: "Disable OOM Killer"}, 398 | prompt.Suggest{Text: "--oom-score-adj", Description: "Tune host’s OOM preferences (-1000 to 1000)"}, 399 | prompt.Suggest{Text: "--pid", Description: "PID namespace to use"}, 400 | prompt.Suggest{Text: "--pids-limit", Description: "Tune container pids limit (set -1 for unlimited)"}, 401 | prompt.Suggest{Text: "--platform", Description: ""}, 402 | prompt.Suggest{Text: "--privileged", Description: "Give extended privileges to this container"}, 403 | prompt.Suggest{Text: "--publish", Description: "Publish a container’s port(s) to the host"}, 404 | prompt.Suggest{Text: "--publish-all", Description: "Publish all exposed ports to random ports"}, 405 | prompt.Suggest{Text: "--read-only", Description: "Mount the container’s root filesystem as read only"}, 406 | prompt.Suggest{Text: "--restart", Description: "Restart policy to apply when a container exits"}, 407 | prompt.Suggest{Text: "--rm", Description: "Automatically remove the container when it exits"}, 408 | prompt.Suggest{Text: "--runtime", Description: "Runtime to use for this container"}, 409 | prompt.Suggest{Text: "--security-opt", Description: "Security Options"}, 410 | prompt.Suggest{Text: "--shm-size", Description: "Size of /dev/shm"}, 411 | prompt.Suggest{Text: "--sig-proxy", Description: "Proxy received signals to the process"}, 412 | prompt.Suggest{Text: "--stop-signal", Description: "Signal to stop a container"}, 413 | prompt.Suggest{Text: "--stop-timeout", Description: ""}, 414 | prompt.Suggest{Text: "--storage-opt", Description: "Storage driver options for the container"}, 415 | prompt.Suggest{Text: "--sysctl", Description: "Sysctl options"}, 416 | prompt.Suggest{Text: "--tmpfs", Description: "Mount a tmpfs directory"}, 417 | prompt.Suggest{Text: "--tty", Description: "Allocate a pseudo-TTY"}, 418 | prompt.Suggest{Text: "--ulimit", Description: "Ulimit options"}, 419 | prompt.Suggest{Text: "--user", Description: "Username or UID (format: <name|uid>[:<group|gid>])"}, 420 | prompt.Suggest{Text: "--userns", Description: "User namespace to use"}, 421 | prompt.Suggest{Text: "--uts", Description: "UTS namespace to use"}, 422 | prompt.Suggest{Text: "--volume", Description: "Bind mount a volume"}, 423 | prompt.Suggest{Text: "--volume-driver", Description: "Optional volume driver for the container"}, 424 | prompt.Suggest{Text: "--volumes-from", Description: "Mount volumes from the specified container(s)"}, 425 | prompt.Suggest{Text: "--workdir", Description: "Working directory inside the container"}, 426 | }, 427 | "save": { 428 | prompt.Suggest{Text: "--output", Description: "Write to a file, instead of STDOUT"}, 429 | }, 430 | "search": { 431 | prompt.Suggest{Text: "--automated", Description: ""}, 432 | prompt.Suggest{Text: "--filter", Description: "Filter output based on conditions provided"}, 433 | prompt.Suggest{Text: "--format", Description: "Pretty-print search using a Go template"}, 434 | prompt.Suggest{Text: "--limit", Description: "Max number of search results"}, 435 | prompt.Suggest{Text: "--no-trunc", Description: "Don’t truncate output"}, 436 | prompt.Suggest{Text: "--stars", Description: ""}, 437 | }, 438 | "stack": { 439 | prompt.Suggest{Text: "--kubeconfig", Description: ""}, 440 | prompt.Suggest{Text: "--orchestrator", Description: "Orchestrator to use (swarm|kubernetes|all)"}, 441 | }, 442 | "start": { 443 | prompt.Suggest{Text: "--attach", Description: "Attach STDOUT/STDERR and forward signals"}, 444 | prompt.Suggest{Text: "--checkpoint", Description: ""}, 445 | prompt.Suggest{Text: "--checkpoint-dir", Description: ""}, 446 | prompt.Suggest{Text: "--detach-keys", Description: "Override the key sequence for detaching a container"}, 447 | prompt.Suggest{Text: "--interactive", Description: "Attach container’s STDIN"}, 448 | }, 449 | "stats": { 450 | prompt.Suggest{Text: "--all", Description: "Show all containers (default shows just running)"}, 451 | prompt.Suggest{Text: "--format", Description: "Pretty-print images using a Go template"}, 452 | prompt.Suggest{Text: "--no-stream", Description: "Disable streaming stats and only pull the first result"}, 453 | prompt.Suggest{Text: "--no-trunc", Description: "Do not truncate output"}, 454 | }, 455 | "stop": { 456 | prompt.Suggest{Text: "--time", Description: "Seconds to wait for stop before killing it"}, 457 | }, 458 | "update": { 459 | prompt.Suggest{Text: "--blkio-weight", Description: "Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)"}, 460 | prompt.Suggest{Text: "--cpu-period", Description: "Limit CPU CFS (Completely Fair Scheduler) period"}, 461 | prompt.Suggest{Text: "--cpu-quota", Description: "Limit CPU CFS (Completely Fair Scheduler) quota"}, 462 | prompt.Suggest{Text: "--cpu-rt-period", Description: ""}, 463 | prompt.Suggest{Text: "--cpu-rt-runtime", Description: ""}, 464 | prompt.Suggest{Text: "--cpu-shares", Description: "CPU shares (relative weight)"}, 465 | prompt.Suggest{Text: "--cpus", Description: ""}, 466 | prompt.Suggest{Text: "--cpuset-cpus", Description: "CPUs in which to allow execution (0-3, 0,1)"}, 467 | prompt.Suggest{Text: "--cpuset-mems", Description: "MEMs in which to allow execution (0-3, 0,1)"}, 468 | prompt.Suggest{Text: "--kernel-memory", Description: "Kernel memory limit"}, 469 | prompt.Suggest{Text: "--memory", Description: "Memory limit"}, 470 | prompt.Suggest{Text: "--memory-reservation", Description: "Memory soft limit"}, 471 | prompt.Suggest{Text: "--memory-swap", Description: "Swap limit equal to memory plus swap: ‘-1’ to enable unlimited swap"}, 472 | prompt.Suggest{Text: "--pids-limit", Description: ""}, 473 | prompt.Suggest{Text: "--restart", Description: "Restart policy to apply when a container exits"}, 474 | }, 475 | "version": { 476 | prompt.Suggest{Text: "--format", Description: "Format the output using the given Go template"}, 477 | prompt.Suggest{Text: "--kubeconfig", Description: ""}, 478 | }, 479 | "service": { 480 | {Text: "create", Description: "Create a new service"}, 481 | {Text: "inspect", Description: "Display detailed information on one or more services"}, 482 | {Text: "logs", Description: "Fetch the logs of a service or task"}, 483 | {Text: "ls", Description: "List services"}, 484 | {Text: "ps", Description: "List the tasks of one or more services"}, 485 | {Text: "rm", Description: "Remove one or more services"}, 486 | {Text: "rollback", Description: "Revert changes to a service’s configuration"}, 487 | {Text: "scale", Description: "Scale one or multiple replicated services"}, 488 | {Text: "update", Description: "Update a service"}, 489 | }, 490 | 491 | "service create": { 492 | prompt.Suggest{Text: "--config", Description: "Specify configurations to expose to the service"}, 493 | prompt.Suggest{Text: "--constraint", Description: "Placement constraints"}, 494 | prompt.Suggest{Text: "--container-label", Description: "Container labels"}, 495 | prompt.Suggest{Text: "--credential-spec", Description: "Credential spec for managed service account (Windows only)"}, 496 | prompt.Suggest{Text: "--detach", Description: "Exit immediately instead of waiting for the service to converge"}, 497 | prompt.Suggest{Text: "--dns", Description: "Set custom DNS servers"}, 498 | prompt.Suggest{Text: "--dns-option", Description: "Set DNS options"}, 499 | prompt.Suggest{Text: "--dns-search", Description: "Set custom DNS search domains"}, 500 | prompt.Suggest{Text: "--endpoint-mode", Description: "Endpoint mode (vip or dnsrr)"}, 501 | prompt.Suggest{Text: "--entrypoint", Description: "Overwrite the default ENTRYPOINT of the image"}, 502 | prompt.Suggest{Text: "--env", Description: "Set environment variables"}, 503 | prompt.Suggest{Text: "--env-file", Description: "Read in a file of environment variables"}, 504 | prompt.Suggest{Text: "--generic-resource", Description: "User defined resources"}, 505 | prompt.Suggest{Text: "--group", Description: "Set one or more supplementary user groups for the container"}, 506 | prompt.Suggest{Text: "--health-cmd", Description: "Command to run to check health"}, 507 | prompt.Suggest{Text: "--health-interval", Description: "Time between running the check (ms|s|m|h)"}, 508 | prompt.Suggest{Text: "--health-retries", Description: "Consecutive failures needed to report unhealthy"}, 509 | prompt.Suggest{Text: "--health-start-period", Description: "Start period for the container to initialize before counting retries towards unstable (ms|s|m|h)"}, 510 | prompt.Suggest{Text: "--health-timeout", Description: "Maximum time to allow one check to run (ms|s|m|h)"}, 511 | prompt.Suggest{Text: "--host", Description: "Set one or more custom host-to-IP mappings (host:ip)"}, 512 | prompt.Suggest{Text: "--hostname", Description: "Container hostname"}, 513 | prompt.Suggest{Text: "--init", Description: "Use an init inside each service container to forward signals and reap processes"}, 514 | prompt.Suggest{Text: "--isolation", Description: "Service container isolation mode"}, 515 | prompt.Suggest{Text: "--label", Description: "Service labels"}, 516 | prompt.Suggest{Text: "--limit-cpu", Description: "Limit CPUs"}, 517 | prompt.Suggest{Text: "--limit-memory", Description: "Limit Memory"}, 518 | prompt.Suggest{Text: "--log-driver", Description: "Logging driver for service"}, 519 | prompt.Suggest{Text: "--log-opt", Description: "Logging driver options"}, 520 | prompt.Suggest{Text: "--mode", Description: "Service mode (replicated or global)"}, 521 | prompt.Suggest{Text: "--mount", Description: "Attach a filesystem mount to the service"}, 522 | prompt.Suggest{Text: "--name", Description: "Service name"}, 523 | prompt.Suggest{Text: "--network", Description: "Network attachments"}, 524 | prompt.Suggest{Text: "--no-healthcheck", Description: "Disable any container-specified HEALTHCHECK"}, 525 | prompt.Suggest{Text: "--no-resolve-image", Description: "Do not query the registry to resolve image digest and supported platforms"}, 526 | prompt.Suggest{Text: "--placement-pref", Description: "Add a placement preference"}, 527 | prompt.Suggest{Text: "--publish", Description: "Publish a port as a node port"}, 528 | prompt.Suggest{Text: "--quiet", Description: "Suppress progress output"}, 529 | prompt.Suggest{Text: "--read-only", Description: "Mount the container’s root filesystem as read only"}, 530 | prompt.Suggest{Text: "--replicas", Description: "Number of tasks"}, 531 | prompt.Suggest{Text: "--replicas-max-per-node", Description: "Maximum number of tasks per node (default 0 = unlimited)"}, 532 | prompt.Suggest{Text: "--reserve-cpu", Description: "Reserve CPUs"}, 533 | prompt.Suggest{Text: "--reserve-memory", Description: "Reserve Memory"}, 534 | prompt.Suggest{Text: "--restart-condition", Description: "Restart when condition is met (“none”|”on-failure”|”any”) (default “any”)"}, 535 | prompt.Suggest{Text: "--restart-delay", Description: "Delay between restart attempts (ns|us|ms|s|m|h) (default 5s)"}, 536 | prompt.Suggest{Text: "--restart-max-attempts", Description: "Maximum number of restarts before giving up"}, 537 | prompt.Suggest{Text: "--restart-window", Description: "Window used to evaluate the restart policy (ns|us|ms|s|m|h)"}, 538 | prompt.Suggest{Text: "--rollback-delay", Description: "Delay between task rollbacks (ns|us|ms|s|m|h) (default 0s)"}, 539 | prompt.Suggest{Text: "--rollback-failure-action", Description: "Action on rollback failure (“pause”|”continue”) (default “pause”)"}, 540 | prompt.Suggest{Text: "--rollback-max-failure-ratio", Description: "Failure rate to tolerate during a rollback (default 0)"}, 541 | prompt.Suggest{Text: "--rollback-monitor", Description: "Duration after each task rollback to monitor for failure (ns|us|ms|s|m|h) (default 5s)"}, 542 | prompt.Suggest{Text: "--rollback-order", Description: "Rollback order (“start-first”|”stop-first”) (default “stop-first”)"}, 543 | prompt.Suggest{Text: "--rollback-parallelism", Description: "Maximum number of tasks rolled back simultaneously (0 to roll back all at once)"}, 544 | prompt.Suggest{Text: "--secret", Description: "Specify secrets to expose to the service"}, 545 | prompt.Suggest{Text: "--stop-grace-period", Description: "Time to wait before force killing a container (ns|us|ms|s|m|h) (default 10s)"}, 546 | prompt.Suggest{Text: "--stop-signal", Description: "Signal to stop the container"}, 547 | prompt.Suggest{Text: "--sysctl", Description: "Sysctl options"}, 548 | prompt.Suggest{Text: "--tty", Description: "Allocate a pseudo-TTY"}, 549 | prompt.Suggest{Text: "--update-delay", Description: "Delay between updates (ns|us|ms|s|m|h) (default 0s)"}, 550 | prompt.Suggest{Text: "--update-failure-action", Description: "Action on update failure (“pause”|”continue”|”rollback”) (default “pause”)"}, 551 | prompt.Suggest{Text: "--update-max-failure-ratio", Description: "Failure rate to tolerate during an update (default 0)"}, 552 | prompt.Suggest{Text: "--update-monitor", Description: "Duration after each task update to monitor for failure (ns|us|ms|s|m|h) (default 5s)"}, 553 | prompt.Suggest{Text: "--update-order", Description: "Update order (“start-first”|”stop-first”) (default “stop-first”)"}, 554 | prompt.Suggest{Text: "--update-parallelism", Description: "Maximum number of tasks updated simultaneously (0 to update all at once)"}, 555 | prompt.Suggest{Text: "--user", Description: "Username or UID (format: [:])"}, 556 | prompt.Suggest{Text: "--with-registry-auth", Description: "Send registry authentication details to swarm agents"}, 557 | prompt.Suggest{Text: "--workdir", Description: "Working directory inside the container"}, 558 | }, 559 | "service inspect": { 560 | prompt.Suggest{Text: "--format", Description: "Format the output using the given Go template"}, 561 | prompt.Suggest{Text: "--pretty", Description: "Print the information in a human friendly format"}, 562 | }, 563 | "service logs": { 564 | prompt.Suggest{Text: "--details", Description: "Show extra details provided to logs"}, 565 | prompt.Suggest{Text: "--follow", Description: "Follow log output"}, 566 | prompt.Suggest{Text: "--no-resolve", Description: "Do not map IDs to Names in output"}, 567 | prompt.Suggest{Text: "--no-task-ids", Description: "Do not include task IDs in output"}, 568 | prompt.Suggest{Text: "--no-trunc", Description: "Do not truncate output"}, 569 | prompt.Suggest{Text: "--raw", Description: "Do not neatly format logs"}, 570 | prompt.Suggest{Text: "--since", Description: "Show logs since timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)"}, 571 | prompt.Suggest{Text: "--tail", Description: "Number of lines to show from the end of the logs"}, 572 | prompt.Suggest{Text: "--timestamps", Description: "Show timestamps"}, 573 | }, 574 | "service ls": { 575 | prompt.Suggest{Text: "--filter", Description: "Filter output based on conditions provided"}, 576 | prompt.Suggest{Text: "--format", Description: "Pretty-print services using a Go template"}, 577 | prompt.Suggest{Text: "--quiet", Description: "Only display IDs"}, 578 | }, 579 | "service ps": { 580 | prompt.Suggest{Text: "--filter", Description: "Filter output based on conditions provided"}, 581 | prompt.Suggest{Text: "--format", Description: "Pretty-print tasks using a Go template"}, 582 | prompt.Suggest{Text: "--no-resolve", Description: "Do not map IDs to Names"}, 583 | prompt.Suggest{Text: "--no-trunc", Description: "Do not truncate output"}, 584 | prompt.Suggest{Text: "--quiet", Description: "Only display task IDs"}, 585 | }, 586 | "service rollback": { 587 | prompt.Suggest{Text: "--detach", Description: "Exit immediately instead of waiting for the service to converge"}, 588 | prompt.Suggest{Text: "--quiet", Description: "Suppress progress output"}, 589 | }, 590 | "service scale": { 591 | prompt.Suggest{Text: "--detach", Description: "Exit immediately instead of waiting for the service to converge"}, 592 | }, 593 | "service update": { 594 | prompt.Suggest{Text: "--args", Description: "Service command args"}, 595 | prompt.Suggest{Text: "--config-add", Description: "Add or update a config file on a service"}, 596 | prompt.Suggest{Text: "--config-rm", Description: "Remove a configuration file"}, 597 | prompt.Suggest{Text: "--constraint-add", Description: "Add or update a placement constraint"}, 598 | prompt.Suggest{Text: "--constraint-rm", Description: "Remove a constraint"}, 599 | prompt.Suggest{Text: "--container-label-add", Description: "Add or update a container label"}, 600 | prompt.Suggest{Text: "--container-label-rm", Description: "Remove a container label by its key"}, 601 | prompt.Suggest{Text: "--credential-spec", Description: "Credential spec for managed service account (Windows only)"}, 602 | prompt.Suggest{Text: "--detach", Description: "Exit immediately instead of waiting for the service to converge"}, 603 | prompt.Suggest{Text: "--dns-add", Description: "Add or update a custom DNS server"}, 604 | prompt.Suggest{Text: "--dns-option-add", Description: "Add or update a DNS option"}, 605 | prompt.Suggest{Text: "--dns-option-rm", Description: "Remove a DNS option"}, 606 | prompt.Suggest{Text: "--dns-rm", Description: "Remove a custom DNS server"}, 607 | prompt.Suggest{Text: "--dns-search-add", Description: "Add or update a custom DNS search domain"}, 608 | prompt.Suggest{Text: "--dns-search-rm", Description: "Remove a DNS search domain"}, 609 | prompt.Suggest{Text: "--endpoint-mode", Description: "Endpoint mode (vip or dnsrr)"}, 610 | prompt.Suggest{Text: "--entrypoint", Description: "Overwrite the default ENTRYPOINT of the image"}, 611 | prompt.Suggest{Text: "--env-add", Description: "Add or update an environment variable"}, 612 | prompt.Suggest{Text: "--env-rm", Description: "Remove an environment variable"}, 613 | prompt.Suggest{Text: "--force", Description: "Force update even if no changes require it"}, 614 | prompt.Suggest{Text: "--generic-resource-add", Description: "Add a Generic resource"}, 615 | prompt.Suggest{Text: "--generic-resource-rm", Description: "Remove a Generic resource"}, 616 | prompt.Suggest{Text: "--group-add", Description: "Add an additional supplementary user group to the container"}, 617 | prompt.Suggest{Text: "--group-rm", Description: "Remove a previously added supplementary user group from the container"}, 618 | prompt.Suggest{Text: "--health-cmd", Description: "Command to run to check health"}, 619 | prompt.Suggest{Text: "--health-interval", Description: "Time between running the check (ms|s|m|h)"}, 620 | prompt.Suggest{Text: "--health-retries", Description: "Consecutive failures needed to report unhealthy"}, 621 | prompt.Suggest{Text: "--health-start-period", Description: "Start period for the container to initialize before counting retries towards unstable (ms|s|m|h)"}, 622 | prompt.Suggest{Text: "--health-timeout", Description: "Maximum time to allow one check to run (ms|s|m|h)"}, 623 | prompt.Suggest{Text: "--host-add", Description: "Add a custom host-to-IP mapping (host:ip)"}, 624 | prompt.Suggest{Text: "--host-rm", Description: "Remove a custom host-to-IP mapping (host:ip)"}, 625 | prompt.Suggest{Text: "--hostname", Description: "Container hostname"}, 626 | prompt.Suggest{Text: "--image", Description: "Service image tag"}, 627 | prompt.Suggest{Text: "--init", Description: "Use an init inside each service container to forward signals and reap processes"}, 628 | prompt.Suggest{Text: "--isolation", Description: "Service container isolation mode"}, 629 | prompt.Suggest{Text: "--label-add", Description: "Add or update a service label"}, 630 | prompt.Suggest{Text: "--label-rm", Description: "Remove a label by its key"}, 631 | prompt.Suggest{Text: "--limit-cpu", Description: "Limit CPUs"}, 632 | prompt.Suggest{Text: "--limit-memory", Description: "Limit Memory"}, 633 | prompt.Suggest{Text: "--log-driver", Description: "Logging driver for service"}, 634 | prompt.Suggest{Text: "--log-opt", Description: "Logging driver options"}, 635 | prompt.Suggest{Text: "--mount-add", Description: "Add or update a mount on a service"}, 636 | prompt.Suggest{Text: "--mount-rm", Description: "Remove a mount by its target path"}, 637 | prompt.Suggest{Text: "--network-add", Description: "Add a network"}, 638 | prompt.Suggest{Text: "--network-rm", Description: "Remove a network"}, 639 | prompt.Suggest{Text: "--no-healthcheck", Description: "Disable any container-specified HEALTHCHECK"}, 640 | prompt.Suggest{Text: "--no-resolve-image", Description: "Do not query the registry to resolve image digest and supported platforms"}, 641 | prompt.Suggest{Text: "--placement-pref-add", Description: "Add a placement preference"}, 642 | prompt.Suggest{Text: "--placement-pref-rm", Description: "Remove a placement preference"}, 643 | prompt.Suggest{Text: "--publish-add", Description: "Add or update a published port"}, 644 | prompt.Suggest{Text: "--publish-rm", Description: "Remove a published port by its target port"}, 645 | prompt.Suggest{Text: "--quiet", Description: "Suppress progress output"}, 646 | prompt.Suggest{Text: "--read-only", Description: "Mount the container’s root filesystem as read only"}, 647 | prompt.Suggest{Text: "--replicas", Description: "Number of tasks"}, 648 | prompt.Suggest{Text: "--replicas-max-per-node", Description: "Maximum number of tasks per node (default 0 = unlimited)"}, 649 | prompt.Suggest{Text: "--reserve-cpu", Description: "Reserve CPUs"}, 650 | prompt.Suggest{Text: "--reserve-memory", Description: "Reserve Memory"}, 651 | prompt.Suggest{Text: "--restart-condition", Description: "Restart when condition is met (“none”|”on-failure”|”any”)"}, 652 | prompt.Suggest{Text: "--restart-delay", Description: "Delay between restart attempts (ns|us|ms|s|m|h)"}, 653 | prompt.Suggest{Text: "--restart-max-attempts", Description: "Maximum number of restarts before giving up"}, 654 | prompt.Suggest{Text: "--restart-window", Description: "Window used to evaluate the restart policy (ns|us|ms|s|m|h)"}, 655 | prompt.Suggest{Text: "--rollback", Description: "Rollback to previous specification"}, 656 | prompt.Suggest{Text: "--rollback-delay", Description: "Delay between task rollbacks (ns|us|ms|s|m|h)"}, 657 | prompt.Suggest{Text: "--rollback-failure-action", Description: "Action on rollback failure (“pause”|”continue”)"}, 658 | prompt.Suggest{Text: "--rollback-max-failure-ratio", Description: "Failure rate to tolerate during a rollback"}, 659 | prompt.Suggest{Text: "--rollback-monitor", Description: "Duration after each task rollback to monitor for failure (ns|us|ms|s|m|h)"}, 660 | prompt.Suggest{Text: "--rollback-order", Description: "Rollback order (“start-first”|”stop-first”)"}, 661 | prompt.Suggest{Text: "--rollback-parallelism", Description: "Maximum number of tasks rolled back simultaneously (0 to roll back all at once)"}, 662 | prompt.Suggest{Text: "--secret-add", Description: "Add or update a secret on a service"}, 663 | prompt.Suggest{Text: "--secret-rm", Description: "Remove a secret"}, 664 | prompt.Suggest{Text: "--stop-grace-period", Description: "Time to wait before force killing a container (ns|us|ms|s|m|h)"}, 665 | prompt.Suggest{Text: "--stop-signal", Description: "Signal to stop the container"}, 666 | prompt.Suggest{Text: "--sysctl-add", Description: "Add or update a Sysctl option"}, 667 | prompt.Suggest{Text: "--sysctl-rm", Description: "Remove a Sysctl option"}, 668 | prompt.Suggest{Text: "--tty", Description: "Allocate a pseudo-TTY"}, 669 | prompt.Suggest{Text: "--update-delay", Description: "Delay between updates (ns|us|ms|s|m|h)"}, 670 | prompt.Suggest{Text: "--update-failure-action", Description: "Action on update failure (“pause”|”continue”|”rollback”)"}, 671 | prompt.Suggest{Text: "--update-max-failure-ratio", Description: "Failure rate to tolerate during an update"}, 672 | prompt.Suggest{Text: "--update-monitor", Description: "Duration after each task update to monitor for failure (ns|us|ms|s|m|h)"}, 673 | prompt.Suggest{Text: "--update-order", Description: "Update order (“start-first”|”stop-first”)"}, 674 | prompt.Suggest{Text: "--update-parallelism", Description: "Maximum number of tasks updated simultaneously (0 to update all at once)"}, 675 | prompt.Suggest{Text: "--user", Description: "Username or UID (format: [:])"}, 676 | prompt.Suggest{Text: "--with-registry-auth", Description: "Send registry authentication details to swarm agents"}, 677 | prompt.Suggest{Text: "--workdir", Description: "Working directory inside the container"}, 678 | }, 679 | }, 680 | } 681 | } 682 | 683 | func (c *Commands) GetDockerSuggestions() []prompt.Suggest { 684 | return c.DockerSuggestions 685 | } 686 | 687 | func (c *Commands) GetDockerSubSuggestions() map[string][]prompt.Suggest { 688 | return c.DockerSubSuggestions 689 | } 690 | 691 | func (c *Commands) IsDockerCommand(kw string) bool { 692 | for _, cmd := range c.DockerSuggestions { 693 | if cmd.Text == kw { 694 | return true 695 | } 696 | } 697 | 698 | return false 699 | } 700 | 701 | func (c *Commands) IsDockerSubCommand(kw string) ([]prompt.Suggest, bool) { 702 | val, ok := c.DockerSubSuggestions[kw] 703 | return val, ok 704 | } 705 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "net/http" 8 | "net/url" 9 | "os" 10 | "os/exec" 11 | "reflect" 12 | "regexp" 13 | "strconv" 14 | "strings" 15 | "time" 16 | 17 | "docker.io/go-docker" 18 | "docker.io/go-docker/api/types" 19 | "docker.io/go-docker/api/types/registry" 20 | 21 | "github.com/c-bata/go-prompt" 22 | "github.com/hashicorp/go-retryablehttp" 23 | commands "github.com/mstrYoda/docker-shell/lib" 24 | "github.com/patrickmn/go-cache" 25 | ) 26 | 27 | var dockerClient *docker.Client 28 | var shellCommands commands.Commands = commands.New() 29 | 30 | //DockerHubResult : Wrap DockerHub API call 31 | type DockerHubResult struct { 32 | PageCount *int `json:"num_pages,omitempty"` 33 | ResultCount *int `json:"num_results,omitempty"` 34 | ItemCountPerPage *int `json:"page_size,omitempty"` 35 | CurrentPage *int `json:"page,omitempty"` 36 | Query *string `json:"query,omitempty"` 37 | Items []registry.SearchResult `json:"results,omitempty"` 38 | } 39 | 40 | func imageFromHubAPI(count int) []registry.SearchResult { 41 | client := retryablehttp.NewClient() 42 | client.HTTPClient = &http.Client{ 43 | Timeout: 1 * time.Second, 44 | } 45 | client.RetryWaitMin = client.HTTPClient.Timeout 46 | client.RetryWaitMax = client.HTTPClient.Timeout 47 | client.RetryMax = 3 48 | client.Logger = nil 49 | url := url.URL{ 50 | Scheme: "https", 51 | Host: "registry.hub.docker.com", 52 | Path: "/v2/repositories/library", 53 | RawQuery: "page=1&page_size=" + strconv.Itoa(count), 54 | } 55 | apiURL := url.String() 56 | response, err := client.Get(apiURL) 57 | if err != nil { 58 | return nil 59 | } 60 | 61 | defer response.Body.Close() 62 | 63 | decoder := json.NewDecoder(response.Body) 64 | searchResult := &DockerHubResult{} 65 | decoder.Decode(searchResult) 66 | if searchResult.Items == nil || len(searchResult.Items) <= 0 { 67 | return nil 68 | } 69 | 70 | return searchResult.Items 71 | } 72 | 73 | func imageFromContext(imageName string, count int) []registry.SearchResult { 74 | ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) 75 | defer cancel() 76 | ctxResponse, err := dockerClient.ImageSearch(ctx, imageName, types.ImageSearchOptions{Limit: count}) 77 | if err != nil { 78 | return nil 79 | } 80 | 81 | if ctxResponse == nil || len(ctxResponse) <= 0 { 82 | return nil 83 | } 84 | 85 | return ctxResponse 86 | } 87 | 88 | func imageFetchCompleter(imageName string, count int) []prompt.Suggest { 89 | searchResult := []registry.SearchResult{} 90 | if imageName != "" { 91 | searchResult = imageFromContext(imageName, 10) 92 | } else { 93 | searchResult = imageFromHubAPI(10) 94 | } 95 | 96 | if searchResult == nil || len(searchResult) <= 0 { 97 | return nil 98 | } 99 | 100 | suggestions := []prompt.Suggest{} 101 | for _, s := range searchResult { 102 | description := "Not Official" 103 | if s.IsOfficial { 104 | description = "Official" 105 | } 106 | suggestions = append(suggestions, prompt.Suggest{Text: s.Name, Description: "(" + description + ") " + s.Description}) 107 | } 108 | return suggestions 109 | } 110 | 111 | var commandExpression = regexp.MustCompile(`(?Pexec|stop|start|run|service create|service inspect|service logs|service ls|service ps|service rollback|service scale|service update|service|pull|attach|build|commit|cp|create|events|export|history|images|import|info|inspect|kill|load|login|logs|ps|push|restart|rm|rmi|save|search|stack|stats|update|version)\s{1}`) 112 | 113 | func getRegexGroups(text string) map[string]string { 114 | if !commandExpression.Match([]byte(text)) { 115 | return nil 116 | } 117 | 118 | match := commandExpression.FindStringSubmatch(text) 119 | result := make(map[string]string) 120 | for i, name := range commandExpression.SubexpNames() { 121 | if i != 0 && name != "" { 122 | result[name] = match[i] 123 | } 124 | } 125 | return result 126 | } 127 | 128 | var memoryCache = cache.New(5*time.Minute, 10*time.Minute) 129 | 130 | func getFromCache(word string) []prompt.Suggest { 131 | cacheKey := "all" 132 | if word != "" { 133 | cacheKey = fmt.Sprintf("completer:%s", word) 134 | } 135 | completer, found := memoryCache.Get(cacheKey) 136 | if !found { 137 | completer = imageFetchCompleter(word, 10) 138 | if completer.([]prompt.Suggest) == nil { 139 | return []prompt.Suggest{} 140 | } 141 | memoryCache.Set(cacheKey, completer, cache.DefaultExpiration) 142 | } 143 | return completer.([]prompt.Suggest) 144 | } 145 | 146 | func completer(d prompt.Document) []prompt.Suggest { 147 | word := d.GetWordBeforeCursor() 148 | 149 | group := getRegexGroups(d.Text) 150 | if group != nil { 151 | command := group["command"] 152 | 153 | if command == "exec" || command == "stop" || command == "port" { 154 | return containerListCompleter(false) 155 | } 156 | 157 | if command == "start" { 158 | return containerListCompleter(true) 159 | } 160 | 161 | if command == "run" { 162 | if word == "-p" { 163 | if len(portMappingSuggestions) > 0 { 164 | return portMappingSuggestions 165 | } 166 | 167 | return portMappingSuggestion() 168 | } 169 | 170 | if len(suggestedImages) > 0 { 171 | return suggestedImages 172 | } 173 | 174 | return imagesSuggestion() 175 | } 176 | 177 | if command == "pull" { 178 | if strings.Index(word, ":") != -1 || strings.Index(word, "@") != -1 { 179 | return []prompt.Suggest{} 180 | } 181 | 182 | if word == "" || len(word) > 2 { 183 | if len(strings.Split(d.Text, " ")) > 2 { 184 | return []prompt.Suggest{} 185 | } 186 | return getFromCache(word) 187 | } 188 | 189 | return []prompt.Suggest{} 190 | } 191 | if val, ok := shellCommands.IsDockerSubCommand(command); ok { 192 | return prompt.FilterHasPrefix(val, word, true) 193 | } 194 | } 195 | 196 | return prompt.FilterHasPrefix(shellCommands.GetDockerSuggestions(), word, true) 197 | } 198 | 199 | func containerListCompleter(all bool) []prompt.Suggest { 200 | suggestions := []prompt.Suggest{} 201 | ctx := context.Background() 202 | cList, _ := dockerClient.ContainerList(ctx, types.ContainerListOptions{All: all}) 203 | 204 | for _, container := range cList { 205 | suggestions = append(suggestions, prompt.Suggest{Text: container.ID, Description: container.Image}) 206 | } 207 | 208 | return suggestions 209 | } 210 | 211 | var portMappingSuggestions []prompt.Suggest 212 | 213 | func portMappingSuggestion() []prompt.Suggest { 214 | images, _ := dockerClient.ImageList(context.Background(), types.ImageListOptions{All: true}) 215 | suggestions := []prompt.Suggest{} 216 | 217 | for _, image := range images { 218 | inspection, _, _ := dockerClient.ImageInspectWithRaw(context.Background(), image.ID) 219 | 220 | exposedPortKeys := reflect.ValueOf(inspection.Config.ExposedPorts).MapKeys() 221 | 222 | for _, exposedPort := range exposedPortKeys { 223 | portAndType := strings.Split(exposedPort.String(), "/") 224 | port := portAndType[0] 225 | portType := portAndType[1] 226 | suggestions = append(suggestions, prompt.Suggest{Text: fmt.Sprintf("-p %s:%s/%s", port, port, portType), Description: getDescription(inspection)}) 227 | } 228 | } 229 | 230 | portMappingSuggestions = suggestions 231 | 232 | return suggestions 233 | } 234 | 235 | func getDescription(inspection types.ImageInspect) string { 236 | desc := "" 237 | if len(inspection.RepoDigests) > 0 && inspection.RepoDigests[0] != "" { 238 | desc = inspection.RepoDigests[0] 239 | } 240 | return desc 241 | } 242 | 243 | var suggestedImages []prompt.Suggest 244 | 245 | func imagesSuggestion() []prompt.Suggest { 246 | images, _ := dockerClient.ImageList(context.Background(), types.ImageListOptions{All: true}) 247 | suggestions := []prompt.Suggest{} 248 | 249 | for _, image := range images { 250 | ins, _, _ := dockerClient.ImageInspectWithRaw(context.Background(), image.ID) 251 | suggestions = append(suggestions, prompt.Suggest{Text: image.ID[7:19], Description: getDescription(ins)}) 252 | } 253 | 254 | suggestedImages = suggestions 255 | 256 | return suggestions 257 | } 258 | 259 | func main() { 260 | dockerClient, _ = docker.NewEnvClient() 261 | ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) 262 | defer cancel() 263 | 264 | if _, err := dockerClient.Ping(ctx); err != nil { 265 | fmt.Println("Couldn't check docker status please make sure docker is running.") 266 | fmt.Println(err) 267 | return 268 | } 269 | go getFromCache("") 270 | for { 271 | dockerCommand := prompt.Input(">>> docker ", 272 | completer, 273 | prompt.OptionTitle("docker prompt"), 274 | prompt.OptionSelectedDescriptionTextColor(prompt.Turquoise), 275 | prompt.OptionInputTextColor(prompt.Fuchsia), 276 | prompt.OptionPrefixBackgroundColor(prompt.Cyan)) 277 | 278 | splittedDockerCommands := strings.Split(dockerCommand, " ") 279 | if splittedDockerCommands[0] == "exit" { 280 | os.Exit(0) 281 | } 282 | 283 | var ps *exec.Cmd 284 | 285 | if splittedDockerCommands[0] == "clear" { 286 | ps = exec.Command("clear") 287 | } else { 288 | ps = exec.Command("docker", splittedDockerCommands...) 289 | } 290 | 291 | res, err := ps.Output() 292 | 293 | if err != nil { 294 | fmt.Println(err) 295 | } 296 | 297 | fmt.Println(string(res)) 298 | 299 | portMappingSuggestions = []prompt.Suggest{} 300 | suggestedImages = []prompt.Suggest{} 301 | } 302 | } 303 | --------------------------------------------------------------------------------