|
| 1 | +Author: MartinRamm |
| 2 | + |
| 3 | +This is something I created to increase my productivity with docker/docker-compose. |
| 4 | +Feel free to create a PR with improvements - but please keep this documentation up to date! |
| 5 | + |
| 6 | +# Requirements |
| 7 | + |
| 8 | +1. `docker` / `docker-compose` must be accessible to non-root users |
| 9 | +1. `fzf` (https://github.com/junegunn/fzf#installation) |
| 10 | + |
| 11 | +# Installation instructions |
| 12 | + |
| 13 | +1. Clone this repository: `git clone https://github.com/MartinRamm/fzf-docker.git` |
| 14 | +1. Add to your `.zshrc` or `.bashrc` file this command: `source /path/to/docker-fzf` |
| 15 | + |
| 16 | +# Overview of available commands |
| 17 | + |
| 18 | +| command | description | fzf mode | command arguments (optional) | |
| 19 | +| ------- | --------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------ | |
| 20 | +| dr | docker restart && open logs (in follow mode) | single | | |
| 21 | +| dl | docker logs (in follow mode) | single | time interval - e.g.: `1m` for 1 minute - (defaults to all available logs) | |
| 22 | +| de | docker exec | single | command to exec (default `/bin/sh`) | |
| 23 | +| ds | docker stop | multiple | | |
| 24 | +| dsa | docker stop all running containers | | | |
| 25 | +| dk | docker kill and remove | multiple | | |
| 26 | +| dka | docker kill and remove all containers | | | |
| 27 | +| drmi | docker remove image (with force) | multiple | | |
| 28 | +| drmia | docker remove all images (with force) | | | |
| 29 | +| dclean | `dka` and `drmia` | | | |
| 30 | +| dcu | docker-compose up (in detached mode) | multiple | path to docker-compose file (defaults to recursive search for `docker-compose.yml` or `docker-compose.yaml`) | |
| 31 | +| dcua | docker-compose up all services (in detached mode) | multiple | path to docker-compose file (defaults to recursive search for `docker-compose.yml` or `docker-compose.yaml`) | |
| 32 | + |
| 33 | +# Learning by doing |
| 34 | +### fzf mode = single |
| 35 | +The image below shows a user opening the logs of the `infrastructure_php_1_6714fd704177` container with the `dl` command. |
| 36 | +The command `dl` was entered into a terminal. The user now typed `php` to narrow the search for containers that contain that phrase. When the correct container was selected, the user pressed `Enter`. |
| 37 | +Alternatively, the user could have used the arrow keys to select the correct container id. |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +### optional command arguments |
| 42 | +This image does the same as above, but with `10m` as an argument. Therefore the command will only show the logs the selected container produced in the last 10 minutes. |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +### fzf mode = multiple |
| 47 | + |
| 48 | +The image below shows a user starting the container `whiteboard` and `redis` with the `dcu` command. |
| 49 | +To mark a containers/services in fzf, press on the `tab` key. To deselect, press `shift + tab`. |
| 50 | +To remove the input, press `Alt + Backspace`. |
| 51 | +Finally, press `Enter` to start the command. Note that when pressing `Enter`, the selected item will *not* be added automatically to your selection. |
| 52 | +If you only want to mark one container, you don't have to select it with tab - you can follow the instuctions of fzf mode single. |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +# License |
| 57 | +This is free and unencumbered software released into the public domain. |
| 58 | + |
| 59 | +Anyone is free to copy, modify, publish, use, compile, sell, or |
| 60 | +distribute this software, either in source code form or as a compiled |
| 61 | +binary, for any purpose, commercial or non-commercial, and by any |
| 62 | +means. |
| 63 | + |
| 64 | +In jurisdictions that recognize copyright laws, the author or authors |
| 65 | +of this software dedicate any and all copyright interest in the |
| 66 | +software to the public domain. We make this dedication for the benefit |
| 67 | +of the public at large and to the detriment of our heirs and |
| 68 | +successors. We intend this dedication to be an overt act of |
| 69 | +relinquishment in perpetuity of all present and future rights to this |
| 70 | +software under copyright law. |
| 71 | + |
| 72 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 73 | +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 74 | +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 75 | +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 76 | +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 77 | +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 78 | +OTHER DEALINGS IN THE SOFTWARE. |
| 79 | + |
| 80 | +For more information, please refer to <http://unlicense.org> |
0 commit comments