-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Enable inspect exec if container is pause/restarting/non-running #32881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c290202 to
5719e7b
Compare
daemon/inspect.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that the design is ok. While I think here we can simplify the code like format:
e := daemon.execCommands.Get(id)
if e == nil {
return nil, errExecNotFound(id)
}
if container := daemon.containers.Get(e.ContainerID); container == nil {
return nil, errExecNotFound(id)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's better, done
5719e7b to
0e87588
Compare
if docker exec exit and at the same the the container is pause,
there could be a chance the `docker exec exit` will fail
```
$ docker exec -ti 388c7f47a06c sh
/ # exit
Error response from daemon: Container 388c7f47a06cce0856266ffd56a2ce2901689ca7a6b9cd741b37652418448f2b is paused, unpause the container before exec
```
To reproduce this error easilly, we can add a sleep in `containerPause`
```
--- a/daemon/pause.go
+++ b/daemon/pause.go
@@ -2,6 +2,7 @@ package daemon
import (
"fmt"
+ "time"
"github.com/docker/docker/container"
)
@@ -25,7 +26,7 @@ func (daemon *Daemon) ContainerPause(name string) error {
func (daemon *Daemon) containerPause(container *container.Container) error {
container.Lock()
defer container.Unlock()
-
+ time.Sleep(time.Second * 5)
// We cannot Pause the container which is not running
if !container.Running {
return errNotRunning{container.ID}
```
Signed-off-by: Lei Jitang <leijitang@huawei.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Another way I could think of is to handle the error coming from getExecConfig but that's much cleaner!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if docker exec exit and at the same the the container is pause,
there could be a chance the `docker exec exit` will fail
```
$ docker exec -ti 388c7f47a06c sh
/ # exit
Error response from daemon: Container 388c7f47a06cce0856266ffd56a2ce2901689ca7a6b9cd741b37652418448f2b is paused, unpause the container before exec
```
To reproduce this error easilly, we can add a sleep in `containerPause`
```
--- a/daemon/pause.go
+++ b/daemon/pause.go
@@ -2,6 +2,7 @@ package daemon
import (
"fmt"
+ "time"
"github.com/docker/docker/container"
)
@@ -25,7 +26,7 @@ func (daemon *Daemon) ContainerPause(name string) error {
func (daemon *Daemon) containerPause(container *container.Container) error {
container.Lock()
defer container.Unlock()
-
+ time.Sleep(time.Second * 5)
// We cannot Pause the container which is not running
if !container.Running {
return errNotRunning{container.ID}
```
upstream pr moby#32881
Signed-off-by: Lei Jitang <leijitang@huawei.com>

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

if docker exec exit and at the same the the container is pause,
there could be a chance the
docker exec exitwill failTo reproduce this error easilly, we can add a sleep in
containerPause- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)