Skip to content

Add support for 'docker exec' - phase 1#7409

Closed
vishh wants to merge 9 commits intomoby:masterfrom
vishh:run_in_phase1
Closed

Add support for 'docker exec' - phase 1#7409
vishh wants to merge 9 commits intomoby:masterfrom
vishh:run_in_phase1

Conversation

@vishh
Copy link
Copy Markdown
Contributor

@vishh vishh commented Aug 5, 2014

This patch brings in support for running a new command in an existing and active container.
Fixes #6777 and #1228.

Some use cases:

  • Perform administrative tasks - add/remove devices, update files, etc
  • Debugging a running container - gdb, ssh
  • Run periodic commands
  • Run commands that are not part of the static container specification.

API
Client: 'docker exec redis touch /tmp/file'
Remote: '/containers/redis/exec'

@vishh
Copy link
Copy Markdown
Contributor Author

vishh commented Aug 5, 2014

Note: This patch depends on docker-archive/libcontainer#141.
The changes to libcontainer in this patch will be reverted once 141 has been merged.

@vishh
Copy link
Copy Markdown
Contributor Author

vishh commented Aug 5, 2014

Ping @crosbymichael @tianon

@cyphar
Copy link
Copy Markdown
Contributor

cyphar commented Aug 5, 2014

+1. An invaluable feature which means that you no longer need to manually use nsinit exec.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strncmp? (Just to avoid all known vulnerable functions)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, strcmp isn't vulnerable unless you're doing cryptographic comparisons (where you need to use strictly O(n) comparisons for any inputs). There's no danger of buffer overflow (since there's no writes occuring) or any real out-of-bounds errors (since IIRC strcmp compares lengths to give you a positive or negative return value).

@SvenDowideit
Copy link
Copy Markdown
Contributor

This UX change desperatly needs documentation, both in cli.md and in the man pages. plus an example of when and how you'd use it.

@vishh
Copy link
Copy Markdown
Contributor Author

vishh commented Aug 8, 2014

@SvenDowideit I will add/update the docs once I get a go ahead from the maintainers for this patch.

@cyphar
Copy link
Copy Markdown
Contributor

cyphar commented Sep 7, 2014

Bumping this. Is there any work happening on this PR?

@vishh
Copy link
Copy Markdown
Contributor Author

vishh commented Sep 8, 2014

I am working on rebasing this to current head. I will update this PR once
thats done.

On Sat, Sep 6, 2014 at 10:31 PM, Aleksa Sarai [email protected]
wrote:

Bumping this. Is there any work happening on this PR?


Reply to this email directly or view it on GitHub
#7409 (comment).

@vishh
Copy link
Copy Markdown
Contributor Author

vishh commented Sep 10, 2014

I have rebased this PR against the current docker head and libcontainer head.

PTAL @crosbymichael @vieux

@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Sep 10, 2014

@vishh This patch need some integration-cli tests.

@vishh
Copy link
Copy Markdown
Contributor Author

vishh commented Sep 10, 2014

@LK4D4: I will add a few tests soon. Meanwhile, it will be helpful to know if the maintainers are committed to merging this feature anytime soon.

Comment thread api/client/hijack.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can body be data? I personally always think about body as about []byte.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. But it is the body of the request.

@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Sep 10, 2014

Phew, I've read all code. This will be a "killer feature".

@vishh
Copy link
Copy Markdown
Contributor Author

vishh commented Sep 11, 2014

@crosbymichael: there should already be a TODO to add resizing support. I
will take a look at the closed connection errors now.

On Wed, Sep 10, 2014, 11:03 PM Sven Dowideit [email protected]
wrote:

Docs LGTM - @jamtur01 https://github.com/jamtur01 @fredlf
https://github.com/fredlf @ostezer https://github.com/ostezer


Reply to this email directly or view it on GitHub
#7409 (comment).

@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Sep 11, 2014

@vishh Seems like closed connection thing is present in master as well: #3631

@vishh
Copy link
Copy Markdown
Contributor Author

vishh commented Sep 11, 2014

Thanks for the pointer @LK4D4. @crosbymichael: If the two issues you raised are not showstoppers for this feature, can we proceed with merging this feature, while I work on resolving those issues? The daemon connection error is not user visible.

@crosbymichael
Copy link
Copy Markdown
Contributor

I think the resize issue maybe a big one

Comment thread api/client/commands.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instantiate

Also, pardon my ignorance, but the "select" what?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fredlf line 2391 in this file...

@fredlf
Copy link
Copy Markdown
Contributor

fredlf commented Sep 12, 2014

Docs LGTM once my nit-picky comments are addressed. Thanks for your contribution!

@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Sep 12, 2014

Need rebase :/ So big patch...

@vishh
Copy link
Copy Markdown
Contributor Author

vishh commented Sep 12, 2014

As per discussions on 'docker-dev' IRC, I will be stashing the CLI and docs
until the daemon can support resizing of tty for 'exec'.
Thanks for the review everyone.

On Fri, Sep 12, 2014 at 11:54 AM, Alexandr Morozov <[email protected]

wrote:

Need rebase :/ So big patch...


Reply to this email directly or view it on GitHub
#7409 (comment).

Modified Attach() method to support docker exec.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <[email protected]> (github: vishh)
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <[email protected]> (github: vishh)
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <[email protected]> (github: vishh)
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <[email protected]> (github: vishh)
…' feature.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <[email protected]> (github: vishh)
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <[email protected]> (github: vishh)
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <[email protected]> (github: vishh)
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <[email protected]> (github: vishh)
@vishh
Copy link
Copy Markdown
Contributor Author

vishh commented Sep 15, 2014

I have removed the 'exec' feature from the CLI.
Ping @crosbymichael , @tianon

@vishh vishh changed the title Add support for 'docker exec' Add support for 'docker exec' - phase 1 Sep 16, 2014
Comment thread integration-cli/docker_cli_run_test.go Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vishh I strongly believe the docs here need the following amendments:

  1. docker should be Docker in most cases
  2. stdin, stdout, etc., should be all capitalized (e.g., .. exit on stdin close >> .. on STDIN close)
  3. Please clarify or point out what "exec" is (used at various places)
  4. Please clarify what "command" refers to (e.g., Error running command.. Does this mean any command? The command passed? A command Docker was just asked to execute?)
  5. lxc > LXC as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ostezer:
The docs have been moved to #8062 for technical reasons.

  1. It is already 'Docker'. By 'docs' are you referring to the source code or the changes to files inside docs/ directory?
  2. Done.
  3. I followed the docs that exist for 'docker run'. Can you point me at specific places in the docs where the usage of 'exec' is not clear? I will be happy to address them.
  4. Can you point me at the line in the source where the usage of 'command' is not clear?
  5. Again point me at the source please.

… resizing of

tty sessions for exec'ed commands.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <[email protected]> (github: vishh)
@vishh
Copy link
Copy Markdown
Contributor Author

vishh commented Sep 16, 2014

Closed in favor of #8062

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Run in support in docker

10 participants