Skip to content

Fix session mode with log drivers that cannot be read - #751

Open
Adham-Kiwan wants to merge 1 commit into
ContainerSSH:mainfrom
Adham-Kiwan:fix-session-mode-log-driver-none
Open

Adham-Kiwan wants to merge 1 commit into
ContainerSSH:mainfrom
Adham-Kiwan:fix-session-mode-log-driver-none

Conversation

@Adham-Kiwan

Copy link
Copy Markdown

Description

Fixes #750.

In session mode, dockerV20Container.attach() calls ContainerAttach with Logs: true. If the container uses a log driver that cannot be read, such as none, Docker returns an attach stream with no output in it, so the SSH session never gets the program's output. Connection mode goes through ContainerExecAttach and doesn't have this problem, which matches the report.

attach() runs before start() in handler_channel.go, so there are never any earlier logs to replay. This PR sets Logs: false.

Testing

  • Reproduced against Docker 29.8.1 with the raw API. I created an alpine container with --log-driver none and attached with stream=1&stdout=1&stderr=1, then started it. With logs=1 the attach stream came back empty. With logs=0 it carried the program's hello output.
  • Added a session-log-driver-none case to TestConformance in internal/docker. It runs the full session-mode conformance suite with HostConfig.LogConfig.Type = "none".
  • go build ./... and go vet ./internal/docker/ pass.

I could not run the conformance suite locally, so please rely on CI for it. My machine is arm64, and containerssh/containerssh-guest-image has no arm64 build.

This change was prepared with help from an AI coding assistant. I reviewed it and checked the behaviour against a real Docker daemon.

In session mode the backend attaches to the container with log replay
turned on. With a log driver that does not support reading, such as
"none", Docker gives back an attach stream that carries no output, so
the session never sees what the program prints. Connection mode is not
affected because it attaches through exec.

The attach happens before the container is started, so there is never
anything to replay. Turn log replay off, and add a session conformance
case that runs with the "none" log driver.

Fixes ContainerSSH#750

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Adham Kiwan <adhamkiwan@outlook.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker backend: session mode fails when the container log driver is "none"

1 participant