Skip to content

Fix docker_container.container_logs to return demultiplexed log content#899

Merged
Junkern merged 4 commits intomasterfrom
copilot/fix-docker-container-logs-headers
Apr 11, 2026
Merged

Fix docker_container.container_logs to return demultiplexed log content#899
Junkern merged 4 commits intomasterfrom
copilot/fix-docker-container-logs-headers

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

docker_container.container_logs currently captures raw Docker log stream frames, so returned values include Docker multiplex headers (\u0001...) instead of actual container output. This breaks expected parity with docker logs output and can surface invalid/non-portable state payloads.

  • Log stream handling

    • Switched container log collection in docker_container create/attach flow from line-scanning raw stream bytes to Docker-aware demultiplexing.
    • For non-TTY containers, logs are decoded with stdcopy.StdCopy so stream headers are removed.
    • For TTY containers, log bytes are copied as-is to preserve expected behavior.
  • Error propagation

    • Replaced fatal/panic behavior in async log collection path with error propagation back to Terraform diagnostics, so failures are surfaced without terminating the provider process.
  • Test updates

    • Updated acceptance expectation for container_logs to plain output (1\n2\n...) rather than header-prefixed frames.
    • Added focused unit tests for both demultiplexed and TTY paths.
func copyContainerLogs(dst io.Writer, reader io.Reader, tty bool) error {
	if tty {
		_, err := io.Copy(dst, reader)
		return err
	}

	_, err := stdcopy.StdCopy(dst, dst, reader)
	return err
}

Copilot AI changed the title [WIP] Fix docker_container container_logs attribute to exclude log headers Fix docker_container.container_logs to return demultiplexed log content Apr 9, 2026
Copilot AI requested a review from Junkern April 9, 2026 20:49
@Junkern Junkern marked this pull request as ready for review April 11, 2026 18:30
@Junkern Junkern merged commit d362cbb into master Apr 11, 2026
6 checks passed
@Junkern Junkern deleted the copilot/fix-docker-container-logs-headers branch April 11, 2026 18:30
mx-moth added a commit to mx-moth/terraform-provider-docker that referenced this pull request Apr 13, 2026
…to-service

* upstream/master:
  chore: Replace git-chglog with git-cliff (kreuzwerker#904)
  feat: Implement docker registry image tags data source (kreuzwerker#903)
  Fix flaky `docker_container` destroy by disabling link removal during delete (kreuzwerker#902)
  Normalize `docker_service` `max_failure_ratio` diffs to prevent `0` vs `0.0` drift (kreuzwerker#901)
  Fix `docker_container.container_logs` to return demultiplexed log content (kreuzwerker#899)
  feat: Add docker import action (kreuzwerker#900)
  docs: add missing docker_exec/buildx examples and align action name to docker_exec (kreuzwerker#898)
  feat: Expose attached container network addresses in `docker_network` data source (kreuzwerker#897)
  chore: Prepare release 4.1.0 (kreuzwerker#896)
  Prevent `docker_container` read panic with CDI `device_requests` by hardening device flattening (kreuzwerker#895)
  Add Plugin Framework `docker_containers` data source for Docker container enumeration (kreuzwerker#893)
  Fix `docker_service` platform flattening hash to prevent platform list drift on updates (kreuzwerker#892)
  fix: Make container deletion idempotent for missing containers (kreuzwerker#891)
  fix(deps): update module github.com/containerd/platforms to v1.0.0-rc.4 (kreuzwerker#889)
  Avoid `docker_container` replacement when only daemon default `log_opts` are present (kreuzwerker#888)
  Add `platform` support to `docker_container` for cross-architecture emulation (kreuzwerker#886)
  Allow `docker_registry_image.auth_config` to mirror provider `registry_auth` optional credentials (kreuzwerker#887)
  feat: Implement docker_exec action (kreuzwerker#885)
  chore: Prepare 4.0.0 release (kreuzwerker#884)
  feat: add selinux_relabel attribute to docker_container volumes (kreuzwerker#883)
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_container container_logs attribute includes Docker log entry headers

2 participants