Signed-off-by: John Howard <jhoward@microsoft.com>
| ... | ... |
@@ -229,8 +229,8 @@ type ImageSearchOptions struct {
|
| 229 | 229 |
// It can be used to resize container ttys and |
| 230 | 230 |
// exec process ttys too. |
| 231 | 231 |
type ResizeOptions struct {
|
| 232 |
- Height int |
|
| 233 |
- Width int |
|
| 232 |
+ Height uint |
|
| 233 |
+ Width uint |
|
| 234 | 234 |
} |
| 235 | 235 |
|
| 236 | 236 |
// VersionResponse holds version information for the client and the server |
| ... | ... |
@@ -313,7 +313,7 @@ type HostConfig struct {
|
| 313 | 313 |
Runtime string `json:",omitempty"` // Runtime to use with this container |
| 314 | 314 |
|
| 315 | 315 |
// Applicable to Windows |
| 316 |
- ConsoleSize [2]int // Initial console size |
|
| 316 |
+ ConsoleSize Box // Initial console size |
|
| 317 | 317 |
Isolation Isolation // Isolation technology of the container (eg default, hyperv) |
| 318 | 318 |
|
| 319 | 319 |
// Contains container's resources (cgroups, ulimits) |
| ... | ... |
@@ -322,3 +322,9 @@ type HostConfig struct {
|
| 322 | 322 |
// Mounts specs used by the container |
| 323 | 323 |
Mounts []mount.Mount `json:",omitempty"` |
| 324 | 324 |
} |
| 325 |
+ |
|
| 326 |
+// Box specifies height and width dimensions. Used for sizing of a console. |
|
| 327 |
+type Box struct {
|
|
| 328 |
+ Height uint |
|
| 329 |
+ Width uint |
|
| 330 |
+} |
| ... | ... |
@@ -135,7 +135,7 @@ func runRun(dockerCli *command.DockerCli, flags *pflag.FlagSet, opts *runOptions |
| 135 | 135 |
// a far better user experience rather than relying on subsequent resizes |
| 136 | 136 |
// to cause things to catch up. |
| 137 | 137 |
if runtime.GOOS == "windows" {
|
| 138 |
- hostConfig.ConsoleSize[0], hostConfig.ConsoleSize[1] = dockerCli.Out().GetTtySize() |
|
| 138 |
+ hostConfig.ConsoleSize.Height, hostConfig.ConsoleSize.Width = dockerCli.Out().GetTtySize() |
|
| 139 | 139 |
} |
| 140 | 140 |
|
| 141 | 141 |
ctx, cancelFun := context.WithCancel(context.Background()) |
| ... | ... |
@@ -16,7 +16,7 @@ import ( |
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
// resizeTtyTo resizes tty to specific height and width |
| 19 |
-func resizeTtyTo(ctx context.Context, client client.ContainerAPIClient, id string, height, width int, isExec bool) {
|
|
| 19 |
+func resizeTtyTo(ctx context.Context, client client.ContainerAPIClient, id string, height, width uint, isExec bool) {
|
|
| 20 | 20 |
if height == 0 && width == 0 {
|
| 21 | 21 |
return |
| 22 | 22 |
} |
| ... | ... |
@@ -48,7 +48,7 @@ func (o *OutStream) RestoreTerminal() {
|
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 | 50 |
// GetTtySize returns the height and width in characters of the tty |
| 51 |
-func (o *OutStream) GetTtySize() (int, int) {
|
|
| 51 |
+func (o *OutStream) GetTtySize() (uint, uint) {
|
|
| 52 | 52 |
if !o.isTerminal {
|
| 53 | 53 |
return 0, 0 |
| 54 | 54 |
} |
| ... | ... |
@@ -59,7 +59,7 @@ func (o *OutStream) GetTtySize() (int, int) {
|
| 59 | 59 |
return 0, 0 |
| 60 | 60 |
} |
| 61 | 61 |
} |
| 62 |
- return int(ws.Height), int(ws.Width) |
|
| 62 |
+ return uint(ws.Height), uint(ws.Width) |
|
| 63 | 63 |
} |
| 64 | 64 |
|
| 65 | 65 |
// NewOutStream returns a new OutStream object from a Writer |
| ... | ... |
@@ -18,10 +18,10 @@ func (cli *Client) ContainerExecResize(ctx context.Context, execID string, optio |
| 18 | 18 |
return cli.resize(ctx, "/exec/"+execID, options.Height, options.Width) |
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
-func (cli *Client) resize(ctx context.Context, basePath string, height, width int) error {
|
|
| 21 |
+func (cli *Client) resize(ctx context.Context, basePath string, height, width uint) error {
|
|
| 22 | 22 |
query := url.Values{}
|
| 23 |
- query.Set("h", strconv.Itoa(height))
|
|
| 24 |
- query.Set("w", strconv.Itoa(width))
|
|
| 23 |
+ query.Set("h", strconv.Itoa(int(height)))
|
|
| 24 |
+ query.Set("w", strconv.Itoa(int(width)))
|
|
| 25 | 25 |
|
| 26 | 26 |
resp, err := cli.post(ctx, basePath+"/resize", query, nil, nil) |
| 27 | 27 |
ensureReaderClosed(resp) |
| ... | ... |
@@ -73,7 +73,8 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e |
| 73 | 73 |
s.Process.Cwd = `C:\` |
| 74 | 74 |
} |
| 75 | 75 |
s.Process.Env = c.CreateDaemonEnvironment(linkedEnv) |
| 76 |
- s.Process.InitialConsoleSize = c.HostConfig.ConsoleSize |
|
| 76 |
+ s.Process.ConsoleSize.Height = c.HostConfig.ConsoleSize.Height |
|
| 77 |
+ s.Process.ConsoleSize.Width = c.HostConfig.ConsoleSize.Width |
|
| 77 | 78 |
s.Process.Terminal = c.Config.Tty |
| 78 | 79 |
s.Process.User.Username = c.Config.User |
| 79 | 80 |
|
| ... | ... |
@@ -198,11 +198,12 @@ func (clnt *client) AddProcess(ctx context.Context, containerID, processFriendly |
| 198 | 198 |
// is only created if it we're not -t. |
| 199 | 199 |
createProcessParms := hcsshim.ProcessConfig{
|
| 200 | 200 |
EmulateConsole: procToAdd.Terminal, |
| 201 |
- ConsoleSize: procToAdd.InitialConsoleSize, |
|
| 202 | 201 |
CreateStdInPipe: true, |
| 203 | 202 |
CreateStdOutPipe: true, |
| 204 | 203 |
CreateStdErrPipe: !procToAdd.Terminal, |
| 205 | 204 |
} |
| 205 |
+ createProcessParms.ConsoleSize[0] = int(procToAdd.ConsoleSize.Height) |
|
| 206 |
+ createProcessParms.ConsoleSize[1] = int(procToAdd.ConsoleSize.Width) |
|
| 206 | 207 |
|
| 207 | 208 |
// Take working directory from the process to add if it is defined, |
| 208 | 209 |
// otherwise take from the first process. |
| ... | ... |
@@ -66,11 +66,12 @@ func (ctr *container) start() error {
|
| 66 | 66 |
createProcessParms := &hcsshim.ProcessConfig{
|
| 67 | 67 |
EmulateConsole: ctr.ociSpec.Process.Terminal, |
| 68 | 68 |
WorkingDirectory: ctr.ociSpec.Process.Cwd, |
| 69 |
- ConsoleSize: ctr.ociSpec.Process.InitialConsoleSize, |
|
| 70 | 69 |
CreateStdInPipe: !isServicing, |
| 71 | 70 |
CreateStdOutPipe: !isServicing, |
| 72 | 71 |
CreateStdErrPipe: !ctr.ociSpec.Process.Terminal && !isServicing, |
| 73 | 72 |
} |
| 73 |
+ createProcessParms.ConsoleSize[0] = int(ctr.ociSpec.Process.ConsoleSize.Height) |
|
| 74 |
+ createProcessParms.ConsoleSize[1] = int(ctr.ociSpec.Process.ConsoleSize.Width) |
|
| 74 | 75 |
|
| 75 | 76 |
// Configure the environment for the process |
| 76 | 77 |
createProcessParms.Environment = setupEnvironmentVariables(ctr.ociSpec.Process.Env) |
| ... | ... |
@@ -49,10 +49,8 @@ type Windows struct {
|
| 49 | 49 |
|
| 50 | 50 |
// Process contains information to start a specific application inside the container. |
| 51 | 51 |
type Process struct {
|
| 52 |
- // Terminal indicates if stderr should NOT be attached for the container. |
|
| 53 |
- Terminal bool `json:"terminal"` |
|
| 54 |
- // ConsoleSize contains the initial h,w of the console size |
|
| 55 |
- InitialConsoleSize [2]int `json:"-"` |
|
| 52 |
+ // Terminal creates an interactive terminal for the container. |
|
| 53 |
+ Terminal bool `json:"terminal,omitempty"` |
|
| 56 | 54 |
// User specifies user information for the process. |
| 57 | 55 |
User User `json:"user"` |
| 58 | 56 |
// Args specifies the binary and arguments for the application to execute. |
| ... | ... |
@@ -62,6 +60,24 @@ type Process struct {
|
| 62 | 62 |
// Cwd is the current working directory for the process and must be |
| 63 | 63 |
// relative to the container's root. |
| 64 | 64 |
Cwd string `json:"cwd"` |
| 65 |
+ // Capabilities are Linux capabilities that are kept for the container. |
|
| 66 |
+ Capabilities []string `json:"capabilities,omitempty" platform:"linux"` |
|
| 67 |
+ // Rlimits specifies rlimit options to apply to the process. |
|
| 68 |
+ Rlimits []Rlimit `json:"rlimits,omitempty" platform:"linux"` |
|
| 69 |
+ // NoNewPrivileges controls whether additional privileges could be gained by processes in the container. |
|
| 70 |
+ NoNewPrivileges bool `json:"noNewPrivileges,omitempty" platform:"linux"` |
|
| 71 |
+ // ApparmorProfile specifies the apparmor profile for the container. |
|
| 72 |
+ ApparmorProfile string `json:"apparmorProfile,omitempty" platform:"linux"` |
|
| 73 |
+ // SelinuxLabel specifies the selinux context that the container process is run as. |
|
| 74 |
+ SelinuxLabel string `json:"selinuxLabel,omitempty" platform:"linux"` |
|
| 75 |
+ // ConsoleSize contains the initial size of the console. |
|
| 76 |
+ ConsoleSize Box `json:"consoleSize" platform:"windows"` |
|
| 77 |
+} |
|
| 78 |
+ |
|
| 79 |
+// Box specifies height and width dimensions. Used for sizing of a console. |
|
| 80 |
+type Box struct {
|
|
| 81 |
+ Height uint |
|
| 82 |
+ Width uint |
|
| 65 | 83 |
} |
| 66 | 84 |
|
| 67 | 85 |
// User specifies specific user (and group) information for the container process. |
| ... | ... |
@@ -198,3 +214,8 @@ type Solaris struct {
|
| 198 | 198 |
// Hooks for container setup and teardown |
| 199 | 199 |
type Hooks struct {
|
| 200 | 200 |
} |
| 201 |
+ |
|
| 202 |
+// Rlimit type and restrictions. Placeholder only to support the Process structure. |
|
| 203 |
+// Not used on Windows, only present for compilation purposes. |
|
| 204 |
+type Rlimit struct {
|
|
| 205 |
+} |