Skip to content

fix(docker): Set explicit container_name on all services#83

Merged
nfebe merged 1 commit intomainfrom
fix/82-cron-container-targeting
Mar 18, 2026
Merged

fix(docker): Set explicit container_name on all services#83
nfebe merged 1 commit intomainfrom
fix/82-cron-container-targeting

Conversation

@nfebe
Copy link
Contributor

@nfebe nfebe commented Mar 18, 2026

EnsureContainerName only named the primary service, leaving others with Docker Compose auto-generated names. This caused cron jobs and backups to fail when targeting secondary services using the {deploymentName}-{serviceName} convention.

EnsureContainerNames now sets container_name on every service: primary gets {deploymentName}, others get {deploymentName}-{service}. Existing container_name values are preserved. The compose file is patched automatically on start/restart/rebuild, so existing deployments pick up correct names on next restart.

Closes #82

EnsureContainerName only named the primary service, leaving others
with Docker Compose auto-generated names. This caused cron jobs and
backups to fail when targeting secondary services using the
{deploymentName}-{serviceName} convention.

EnsureContainerNames now sets container_name on every service:
primary gets {deploymentName}, others get {deploymentName}-{service}.
Existing container_name values are preserved. The compose file is
patched automatically on start/restart/rebuild, so existing
deployments pick up correct names on next restart.

Closes #82

Signed-off-by: nfebe <fenn25.fn@gmail.com>
@sourceant
Copy link

sourceant bot commented Mar 18, 2026

Code Review Summary

This PR fixes an issue where only the primary service was assigned a static container name, causing targeting issues for cron jobs/backups on secondary services. It now ensures every service in a compose file has an explicit container_name based on the deployment name.

🚀 Key Improvements

  • Standardized container naming: {deploymentName} for primary, {deploymentName}-{service} for others.
  • Automatic patching: The compose file is updated during start, restart, and rebuild cycles.
  • Preservation: Existing container_name values are respected and not overwritten.

💡 Minor Suggestions

  • Ensure deterministic primary service selection when 'app' is missing by sorting service keys.
  • Add error logging for failed disk writes when patching the compose file.

Copy link

@sourceant sourceant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review complete. See the overview comment for a summary.

@nfebe nfebe merged commit bbb89ac into main Mar 18, 2026
5 checks passed
@nfebe nfebe deleted the fix/82-cron-container-targeting branch March 18, 2026 00:17
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.

bug: Cron jobs do not target containers directly

1 participant