docker / docker/cli

Enhancement: docker exec -container_index ...

Open
#2,606 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area/ux kind/enhancement
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Often times I start a new container in one terminal, then docker exec something in another terminal. I use zsh and I have the completions installed, so docker exec <TAB> lets me to select a container quickly.
However I think that accessing a container by index (i.e like cd -3 or git show HEAD~7) can also be useful and more convenient. docker exec -4 /bin/bash will refer to the fourth container in docker 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the docker exec entry point and the zsh Docker completion script mentioned in the issue, then determine whether container-index handling belongs in the CLI or completion layer. Compare the requested index against docker ps ordering and define behavior for invalid or changing indexes; done means docker exec -4 resolves the intended container with coverage for the chosen layer.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go, zsh
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.