Preserve service network aliases and healthcheck in generated Compose output#91
Draft
Copilot wants to merge 3 commits into
Draft
Preserve service network aliases and healthcheck in generated Compose output#91Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Copilot
AI
changed the title
[WIP] Fix issue #89 to preserve network attachments and healthcheck
Preserve service network aliases and healthcheck in generated Compose output
Jun 8, 2026
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.
docker-autocomposewas collapsing service network attachments to name-only output, dropping per-network attributes likeAliases, and it was not serializingConfig.Healthcheck. This change keeps service-level network details fromdocker inspectand maps healthcheck fields into Compose-compatible output while preserving existing default-network behavior.Service network attachment fidelity
NetworkSettings.Networksas structured per-network config instead of a set of names.Aliasesper network.networks:as:Top-level network declarations
networksgeneration unchanged.services.<name>.networksand top-levelnetworkscoexist correctly.Healthcheck serialization
Test→testInterval→intervalTimeout→timeoutRetries→retriesStartPeriod→start_period<ns>ns).Regression coverage
network_mode) behavior.Original prompt
Implement a fix for issue #89 in
Red5d/docker-autocompose.Context:
Red5d/docker-autocomposehttps://github.com/Red5d/docker-autocompose/issues/89https://github.com/Red5d/docker-autocompose/issues/89#issuecomment-4645166865Observed problem:
docker inspectdata.NetworkSettings.Networks.<network>.Aliasesis not preserved.Config.Healthcheckentirely.Current implementation details:
src/autocompose.py, service networks are currently collapsed into a set of network names, which loses nested per-network attributes like aliases.networks:output cannot currently express mapping-form network configuration.Config.Healthcheckinto Composehealthcheck:output.Required changes:
docker inspect.cattrs["NetworkSettings"]["Networks"].networks:in Compose-compatible form:networks:entries.healthcheckserialization.cattrs["Config"]["Healthcheck"].healthcheckkeys:Test->testInterval->intervalTimeout->timeoutRetries->retriesStartPeriod->start_periodImplementation guidance:
Deliverable:
masterimplementing the above fixes with a concise PR title and description.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Try and figure out what the actual issue is here and what should be done to fix it.
Assistant: The actual issue is not just “aliases are lost” — it’s that
docker-autocomposecurrently reconstructs only a very shallow subset of network and container config, so it drops per-network service details likealiases, and it also omitshealthcheck. The code is reading the raw Docker inspect data, but it never maps those fields into Compose output.Specifically:
src/autocompose.py,values["networks"]is built as a set of network names fromNetworkSettings.Networks.keys(). That means fields under each network likeAliases,IPv4Address, etc. are discarded immediately. Later it only emits top-level network definitions likeexternalandname, not service-level network attachments. So aliases cannot survive with the current data model.Config.Healthcheckand converts it into Composehealthcheck:output.NetworkSettings.Networks.<network>.Aliases, and healthcheck underConfig.Healthcheck, but the generator never serializes either of those into the compose structure.The key code causing the network-loss problem is here:
What the bug really is
docker-autocomposeis treating:as if they were the same thing.
But in Compose they are different:
networks:defines the network objectsThis pull request was created from Copilot chat.