Skip to content

Comments

fix: update docker event format to use template syntax#62

Closed
kiitosu wants to merge 1 commit intolocalstack:mainfrom
kiitosu:fix/docker_events_format
Closed

fix: update docker event format to use template syntax#62
kiitosu wants to merge 1 commit intolocalstack:mainfrom
kiitosu:fix/docker_events_format

Conversation

@kiitosu
Copy link

@kiitosu kiitosu commented Sep 22, 2025

Summary

This PR fixes the issue where LocalStack container state in the VSCode extension stays in starting or stopping and never transitions to running or stopped.

my environment

VSCode: Version: 1.104.1
LocalStack Toolkit: 1.2.3
macOS (Apple M1 Pro): Sequoia 15.7
docker: 20.10.21, build baeda1f82a

Problem

  • In my environment, LocalStack state was stuck at starting / stopping.
  • Checking Docker directly (docker ps) showed that the container itself had already reached running / stopped.
  • However, the extension did not detect the state transition correctly.

Investigation

When inspecting Docker events:

docker events --filter container=localstack-main \
  --filter event=start --filter event=stop --filter event=kill \
  --filter event=die --filter event=restart \
  --format json

No events were captured.

But with:

docker events --filter container=localstack-main \
  --filter event=start --filter event=stop --filter event=kill \
  --filter event=die --filter event=restart \
  --format '{{json .}}'

→ Events were captured correctly (start, stop, die, etc.).

This difference in formatting prevented the extension from correctly updating the container state.

Fix

  • Use --format '{{json .}}' when capturing Docker events.
  • With this change, the extension correctly updates container state from startingrunning and stoppingstopped.

Verification

  • Built the extension locally with make vsix.
  • Installed the generated .vsix file in VSCode.
  • Verified that LocalStack state now transitions properly between running and stopped.

@skyrpex
Copy link
Collaborator

skyrpex commented Sep 22, 2025

@kiitosu thanks for the contribution!

Aren't --output json and --format '{{json .}}' equivalent? I can't see any differences in the output for both of them 🤔.

Edit: I use Docker version 28.4.0, build d8eb465 though. Maybe the behavior changed in newer versions than Docker 20.10.21, build baeda1f82a. Will check it out.

Edit 2: Asked AI about it. This is the response:

• The ‎--format '{{json .}}' syntax has been supported for several years (since Docker 17.06).
• The shorthand ‎--format json (without the Go template) is a newer addition and only works in recent Docker CLI versions (23.0 and later, released in early 2023).

@skyrpex skyrpex added the bug Something isn't working label Sep 22, 2025
@kiitosu
Copy link
Author

kiitosu commented Sep 22, 2025

@skyrpex
Thank you for your reply!
You were right — the issue was caused by my old Docker version.

@kiitosu kiitosu closed this Sep 22, 2025
@anisaoshafi
Copy link
Collaborator

Thanks @kiitosu for the quick feedback and raising this issue 🐛

Since this does impact users that are stuck on older docker versions, we'll find some time to tackle it properly.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants