summaryrefslogtreecommitdiff
path: root/daemon/oci_opts.go
diff options
context:
space:
mode:
authorPaweł Gronowski <pawel.gronowski@docker.com>2022-05-12 14:54:44 +0200
committerPaweł Gronowski <pawel.gronowski@docker.com>2022-05-19 07:57:27 +0200
commit85a7f5a09af9c2d387c89df4d9de61c4322a2843 (patch)
treefcaa79645c8c65f160906fd5a6c5ef4636cdb057 /daemon/oci_opts.go
parent1a0587bd766e3ab1f6dbe808a94a41a2f54d9126 (diff)
downloaddocker-85a7f5a09af9c2d387c89df4d9de61c4322a2843.tar.gz
daemon/linux: Set console size on creation
On Linux the daemon was not respecting the HostConfig.ConsoleSize property and relied on cli initializing the tty size after the container was created. This caused a delay between container creation and the tty actually being resized. This is also a small change to the api description, because HostConfig.ConsoleSize is no longer Windows-only. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Diffstat (limited to 'daemon/oci_opts.go')
-rw-r--r--daemon/oci_opts.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/daemon/oci_opts.go b/daemon/oci_opts.go
new file mode 100644
index 0000000000..c824999d50
--- /dev/null
+++ b/daemon/oci_opts.go
@@ -0,0 +1,23 @@
+package daemon
+
+import (
+ "context"
+
+ "github.com/containerd/containerd/containers"
+ coci "github.com/containerd/containerd/oci"
+ "github.com/docker/docker/container"
+ specs "github.com/opencontainers/runtime-spec/specs-go"
+)
+
+// WithConsoleSize sets the initial console size
+func WithConsoleSize(c *container.Container) coci.SpecOpts {
+ return func(ctx context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) error {
+ if c.HostConfig.ConsoleSize[0] > 0 || c.HostConfig.ConsoleSize[1] > 0 {
+ s.Process.ConsoleSize = &specs.Box{
+ Height: c.HostConfig.ConsoleSize[0],
+ Width: c.HostConfig.ConsoleSize[1],
+ }
+ }
+ return nil
+ }
+}