Open Jongy opened 4 years ago
Hey @Jongy, how are you? Docker cli provide the docker exec container_name
or docker exec container_hash
to achieve this point. Why this could be a significant improvement?
Hey @maximillianfx , the idea I had is to add another shortcut for naming containers in the Docker CLI (I mentioned docker exec
specifically, but this applies to all subcommands).
Autocompletion for container names / hashes is useful, but for faster typing, when I remember which containers I ran lately, I find the cd -X
notation more convenient - that is, faster to type.
+1, I hate using the zsh completions as they are currently.. too much time wasted on docker exec my_cont<TAB>
and then going back with the cursor before the container name to add the -it
(the zsh completions don't work if you add the CLI switches before the container name)
-1
will probably be problematic, but possibly a literally just doing something like ~3
could work.
Bash doesn't seem to interpret ~
in that case, at least.
Fwiw I keep a shell function, dplq() { docker ps -lq }
, to get my last container.
Often times I start a new container in one terminal, then
docker exec
something in another terminal. I usezsh
and I have the completions installed, sodocker exec <TAB>
lets me to select a container quickly. However I think that accessing a container by index (i.e likecd -3
orgit show HEAD~7
) can also be useful and more convenient.docker exec -4 /bin/bash
will refer to the fourth container indocker ps
, and so on.I thought to add it as part of the
zsh
Docker completion script, but perhaps it should be added in the CLI itself?I couldn't find any existing issue requesting such a feature, hence opening a new one.