Yes, but preserve the old DNS name as a temporary network alias and update every client before removing it.
This becomes a real compatibility question when a Compose service is renamed while sibling containers, health checks, reverse proxies, and stored connection strings still resolve the old service name. Start with a disposable path or account, keep the previous working state available, and judge the design by the original workload rather than by a one-time connection test.
Define When Docker Service-Name Migration Can Work
The supported branch is a staged rename with both old and new aliases. The competing branch is an immediate rename that removes the only discoverable name. Record versions, identities, addresses, mount paths, permissions, and the current observable state before changing either branch.
The relevant Compose service discovery defines the first compatibility boundary. Use it to constrain the claim, then verify the same behavior on this exact home server instead of treating a documented feature as proof that the full design works.
Write the decision rule before testing: success must produce both aliases resolve to the recreated container and all clients reconnect by name rather than an old IP; failure includes the old name returns NXDOMAIN, a client pins the former IP, or health checks still call the removed name. This prevents a partial connection or clean command exit from being misread as end-to-end compatibility.
Run the Smallest Test That Separates the Designs
Use one controlled discriminator: attach a disposable client to the same network, resolve both names, recreate the service, and repeat connection and health-check tests. Hold the client, workload, file set, account, and timing constant so the changed component is the only plausible explanation.
Use Compose service definitions to choose the second observation that matters for this path. Capture both sides of the transaction: resolver or route, negotiated protocol, process identity, exit status, latency, transferred bytes, and any recovery event.
Repeat the test after the lifecycle event named in the titleโrecreation, reconnect, remount, restart, failover, or client change. A design that works only while old sockets, caches, or credentials remain warm has not passed.
docker compose config
docker network inspect app_default
getent hosts old-name new-name
Read the Pass, Fail, and Exception Signals
PASS: both aliases resolve to the recreated container and all clients reconnect by name rather than an old IP. Save the exact versions and topology that produced this state, because the conclusion applies to those conditions rather than every implementation of the protocol.
FAIL: the old name returns NXDOMAIN, a client pins the former IP, or health checks still call the removed name. Check shared dependencies such as DNS, MTU, identity, firewall state, storage latency, and cached sessions before declaring either primary branch responsible.
EXCEPTION: restore the old service key or alias, inventory remaining consumers, and retry after their configuration is migrated. Do not widen privileges, delete source data, weaken transport security, or replace working storage until a repeatable observation identifies which boundary failed.
Validate the Decision Under the Real Workload
Apply only the action matched to the observed branch, then rerun the original workload. Keep the design only when both aliases resolve to the recreated container and all clients reconnect by name rather than an old IP across two relevant lifecycle cycles and under the expected concurrent load.
Use the dedicated proxy networks to verify the closest dependent workflow. Its access, timing, and recovery behavior must remain unchanged while the new design is active.
Stop and return to the saved state if the old name returns NXDOMAIN, a client pins the former IP, or health checks still call the removed name. Escalate with timestamps, exact versions, route or mount evidence, and the smallest reproduction rather than adding another workaround.
Cross-check the result against the local DNS overrides so risk is not merely moved into another network, identity, backup, or storage layer.
For Docker service-name migration, the qualified answer is therefore the opening judgmentโnot an unconditional yes. The observable pass state is the acceptance line; the fail state is the rollback line.
FAQ
Does container_name preserve the old service DNS name?
Not reliably by itself. Test the network aliases that attached clients actually resolve.
Do open database connections survive the rename?
Existing sockets may live briefly, but reconnects must resolve a valid name; test after recreation.
When can the old alias be removed?
Only after logs and configuration searches show no clients querying it across at least one normal restart cycle.
Support & Tips
More to Read

Can a Self-Hosted Gallery Preserve Apple Live Photo Pairing?
A conditional home-server decision for Apple Live Photo pairing, with controlled tests, result interpretation, rollback, and focused FAQs.

Can You Import Google Takeout and Phone Backups Into One Photo Library?
A conditional home-server decision for combined photo import, with controlled tests, result interpretation, rollback, and focused FAQs.

Can Immich Use an External Library Without Taking Ownership of the Files?
A conditional home-server decision for Immich external-library ownership, with controlled tests, result interpretation, rollback, and focused FAQs.

