Skip to content

dockertest.Resource.Exec fails with "Unrecognized input header: 100" #472

@thediveo

Description

@thediveo

Preflight checklist

Ory Network Project

No response

Describe the bug

dockertest.Resource.Exec(..., dockertest.ExecOptions{StdOut: ..., StdErr: ..., TTY: true}) fails with Start exec failed: Unrecognized input header: 100. This happens regardless of whether the corresponding container has been created with or without Tty: true.

Reproducing the bug

By("spinning up a Docker container with stand-alone containerd, courtesy of the KinD k8s sig")
pool := Successful(dockertest.NewPool("unix:///var/run/docker.sock"))
_ = pool.RemoveContainerByName(kindischName)
// The necessary container start arguments come from KinD's Docker node
// provisioner, see:
// https://github.com/kubernetes-sigs/kind/blob/3610f606516ccaa88aa098465d8c13af70937050/pkg/cluster/internal/providers/docker/provision.go#L133
//
// Please note that --privileged already implies switching off AppArmor.
//
// Please note further, that currently some Docker client CLI flags
// don't translate into dockertest-supported options.
//
// docker run -it --rm --name kindisch-...
//   --privileged
//   --cgroupns=private
//   --init=false
//   --volume /dev/mapper:/dev/mapper
//   --device /dev/fuse
//   --tmpfs /tmp
//   --tmpfs /run
//   --volume /var
//   --volume /lib/modules:/lib/modules:ro
//   kindisch-...
providerCntr = Successful(pool.BuildAndRunWithBuildOptions(
    &dockertest.BuildOptions{
	    ContextDir: "./test/kindisch", // sorry, couldn't resist the pun.
	    Dockerfile: "Dockerfile",
	    BuildArgs: []docker.BuildArg{
		    {Name: "KINDEST_BASE_TAG", Value: test.KindestBaseImageTag},
	    },
    },
    &dockertest.RunOptions{
	    Name:       kindischName,
	    Privileged: true,
	    Mounts: []string{
		    "/dev/mapper:/dev/mapper",
		    "/var",
		    "/lib/modules:/lib/modules:ro",
	    },
	    Tty: true,
    }, func(hc *docker.HostConfig) {
	    hc.Init = false
	    hc.Tmpfs = map[string]string{
		    "/tmp": "",
		    "/run": "",
	    }
	    hc.Devices = []docker.Device{
		    {PathOnHost: "/dev/fuse"},
	    }
    }))
func Exec(cntr *dockertest.Resource, args ...string) {
	gi.GinkgoHelper()
	exitCode, err := cntr.Exec(
		append([]string{"ctr"}, args...),
		dockertest.ExecOptions{
			StdOut: gi.GinkgoWriter,
			StdErr: gi.GinkgoWriter,
			TTY:    true,
		},
	)
	g.Expect(err).NotTo(g.HaveOccurred(), "failed: ctr %s", strings.Join(args, " "))
	g.Expect(exitCode).To(g.BeZero(), "ctr command failed with non-zero exit code")
}

Relevant log output

No response

Relevant configuration

No response

Version

v3.10.0

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Docker

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions