Also add docs to detach events
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
... | ... |
@@ -48,18 +48,10 @@ var ( |
48 | 48 |
errInvalidNetwork = fmt.Errorf("invalid network settings while building port map info") |
49 | 49 |
) |
50 | 50 |
|
51 |
-// AttachError represents errors of attach |
|
52 |
-type AttachError interface { |
|
53 |
- IsDetached() bool |
|
54 |
-} |
|
55 |
- |
|
56 |
-type detachError struct{} |
|
57 |
- |
|
58 |
-func (e detachError) IsDetached() bool { |
|
59 |
- return true |
|
60 |
-} |
|
51 |
+// DetachError is special error which returned in case of container detach. |
|
52 |
+type DetachError struct{} |
|
61 | 53 |
|
62 |
-func (e detachError) Error() string { |
|
54 |
+func (DetachError) Error() string { |
|
63 | 55 |
return "detached from container" |
64 | 56 |
} |
65 | 57 |
|
... | ... |
@@ -507,7 +499,7 @@ func copyEscapable(dst io.Writer, src io.ReadCloser, keys []byte) (written int64 |
507 | 507 |
} |
508 | 508 |
if i == len(keys)-1 { |
509 | 509 |
src.Close() |
510 |
- return 0, detachError{} |
|
510 |
+ return 0, DetachError{} |
|
511 | 511 |
} |
512 | 512 |
nr, er = src.Read(buf) |
513 | 513 |
} |
... | ... |
@@ -121,8 +121,7 @@ func (daemon *Daemon) containerAttach(c *container.Container, stdin io.ReadClose |
121 | 121 |
} |
122 | 122 |
err := <-c.Attach(stdinPipe, stdout, stderr, keys) |
123 | 123 |
if err != nil { |
124 |
- e, ok := err.(container.AttachError) |
|
125 |
- if ok && e.IsDetached() { |
|
124 |
+ if _, ok := err.(container.DetachError); ok { |
|
126 | 125 |
daemon.LogContainerEvent(c, "detach") |
127 | 126 |
} else { |
128 | 127 |
logrus.Errorf("attach failed with error: %v", err) |
... | ... |
@@ -222,11 +222,10 @@ func (d *Daemon) ContainerExecStart(ctx context.Context, name string, stdin io.R |
222 | 222 |
return fmt.Errorf("context cancelled") |
223 | 223 |
case err := <-attachErr: |
224 | 224 |
if err != nil { |
225 |
- e, ok := err.(container.AttachError) |
|
226 |
- if !ok || !e.IsDetached() { |
|
227 |
- return fmt.Errorf("attach failed with error: %v", err) |
|
225 |
+ if _, ok := err.(container.DetachError); !ok { |
|
226 |
+ return fmt.Errorf("exec attach failed with error: %v", err) |
|
228 | 227 |
} |
229 |
- d.LogContainerEvent(c, "detach") |
|
228 |
+ d.LogContainerEvent(c, "exec_detach") |
|
230 | 229 |
} |
231 | 230 |
} |
232 | 231 |
return nil |
... | ... |
@@ -99,6 +99,8 @@ Some container-related events are not affected by container state, so they are n |
99 | 99 |
* **export** emitted by `docker export` |
100 | 100 |
* **exec_create** emitted by `docker exec` |
101 | 101 |
* **exec_start** emitted by `docker exec` after **exec_create** |
102 |
+* **detach** emitted when client is detached from container process |
|
103 |
+* **exec_detach** emitted when client is detached from exec process |
|
102 | 104 |
|
103 | 105 |
Running `docker rmi` emits an **untag** event when removing an image name. The `rmi` command may also emit **delete** events when images are deleted by ID directly or by deleting the last tag referring to the image. |
104 | 106 |
|
... | ... |
@@ -121,6 +123,8 @@ This section lists each version from latest to oldest. Each listing includes a |
121 | 121 |
* `GET /images/search` now takes a `filters` query parameter. |
122 | 122 |
* `GET /events` now supports a `reload` event that is emitted when the daemon configuration is reloaded. |
123 | 123 |
* `GET /events` now supports filtering by daemon name or ID. |
124 |
+* `GET /events` now supports a `detach` event that is emitted on detaching from container process. |
|
125 |
+* `GET /events` now supports an `exec_detach ` event that is emitted on detaching from exec process. |
|
124 | 126 |
* `GET /images/json` now supports filters `since` and `before`. |
125 | 127 |
* `POST /containers/(id or name)/start` no longer accepts a `HostConfig`. |
126 | 128 |
* `POST /images/(name)/tag` no longer has a `force` query parameter. |
... | ... |
@@ -2404,7 +2404,7 @@ Get container events from docker, either in real time via streaming, or via poll |
2404 | 2404 |
|
2405 | 2405 |
Docker containers report the following events: |
2406 | 2406 |
|
2407 |
- attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update |
|
2407 |
+ attach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update |
|
2408 | 2408 |
|
2409 | 2409 |
Docker images report the following events: |
2410 | 2410 |
|
... | ... |
@@ -21,7 +21,7 @@ parent = "smn_cli" |
21 | 21 |
|
22 | 22 |
Docker containers report the following events: |
23 | 23 |
|
24 |
- attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update |
|
24 |
+ attach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update |
|
25 | 25 |
|
26 | 26 |
Docker images report the following events: |
27 | 27 |
|
... | ... |
@@ -18,7 +18,7 @@ information and real-time information. |
18 | 18 |
|
19 | 19 |
Docker containers will report the following events: |
20 | 20 |
|
21 |
- attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update |
|
21 |
+ attach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update |
|
22 | 22 |
|
23 | 23 |
Docker images report the following events: |
24 | 24 |
|