Attach to externally-started LS container#190
Draft
carole-lavillonniere wants to merge 5 commits intootel-tracingfrom
Draft
Attach to externally-started LS container#190carole-lavillonniere wants to merge 5 commits intootel-tracingfrom
carole-lavillonniere wants to merge 5 commits intootel-tracingfrom
Conversation
When `lstk start` is run and a LocalStack container is already running (started outside lstk, e.g. via docker run or Compose), lstk now attaches to it rather than failing or trying to start a duplicate. Detection uses two complementary strategies: - Docker API: `FindRunningByImage` filters by image repo + bound host port via the `ancestor` filter, returning the running container regardless of its name or tag - HTTP fallback: if the Docker filter misses it (different image name, mid-restart), `/_localstack/info` is probed on the configured port Behaviour on attach: - Same version as config: "LocalStack is already running" (exit 0) - Different version: warning with both versions shown (exit 0) - Port in use by non-LocalStack process: existing error (exit 1) `lstk stop` also gains the same fallback: if no container matches the configured name, `FindRunningByImage` is used to locate and stop the externally-started container. `ContainerRemove` conflict/not-found errors (e.g. container started with --rm) are now silently ignored since removal was already in progress.
- start: attach to container started outside lstk (by image prefix + port), warn on version mismatch, skip pull/start - stop: find and stop external containers via FindRunningByImage fallback - status: same resolveRunningContainerName fallback so external containers are reflected correctly - docker: fix FindRunningByImage to match by image string prefix instead of Docker ancestor filter (which fails when untagged image isn't locally pulled) - integration tests: TestStartCommandAttachesExternalContainer, TestStopCommandStopsExternalContainer using tagged alpine as fake image
Logout's "LocalStack is still running" hint now detects containers started outside lstk, consistent with stop and status.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lstk startnow attaches to an already-running LocalStack container instead of failing — warns if the running version differs from config, exits 0 in both caseslstk stopgains the same fallback: locates and stops externally-started containersTowards DRG-553
Started outside of
lstk(eg CLI v1, or locally built and ran in docker):Already running but with another version:
Status command shows details about the version and container name:
Possible improvement:
Add interactivity and let user decide if the existing container should be picked up or replaced