Skip to content

stacker agent deploy-app creates the redeployed container on a different, isolated network than the rest of the stack #237

Description

@vsilent

Summary

After the #211 fix, stacker agent deploy-app <app> --image <img> --force succeeds (no more "undefined network" error) and reports "status": "deployed", but the redeployed container actually ends up broken: it's placed on a different Docker network than its sibling services, so service-name DNS resolution fails and the app crash-loops.

Steps to reproduce

  1. Full cloud deploy of a project with an app + a service it depends on via hostname, e.g. miniflux (trydirect/stacker-project-examples) — DATABASE_URL uses hostname postgres.
    stacker deploy --target cloud --key htz-0 --force-new --watch
    This produces containers project-app-1 / project-postgres-1 on network default_network (per the Remote compose references undefined network default_network #211-fixed renderer).
  2. Redeploy just the app container via the agent:
    stacker agent deploy-app miniflux --image miniflux/miniflux:latest --force
    Reports success:
    { "status": "deployed", "container_state": "starting", ... }
  3. Check container health shortly after — the new container is crash-looping:
    stacker agent health
    CONTAINER            STATE
    miniflux              restarting
    project-postgres-1    running
    project-app-1         running   <- old container, untouched
    
    (Note: agent deploy-app created a new container literally named miniflux, alongside the original project-app-1 — a separate issue in itself, but focusing on the network problem here.)

Root cause (confirmed via docker inspect/docker network ls on the target server)

  • New miniflux container's logs: dial tcp: lookup postgres on 127.0.0.11:53: server misbehaving — Docker embedded DNS can't resolve postgres.
  • docker inspect miniflux → networks: project_default_network (note the project_ prefix).
  • docker inspect project-postgres-1 → networks: default_network and project_app-network (no project_default_network).
  • docker network ls shows both default_network and project_default_network exist as separate networks on the host; docker network inspect project_default_network has zero containers attached despite the miniflux container's inspect output claiming membership in it (empty EndpointID — the attach may not have actually completed, likely downstream of the container's own crash-restart loop).

So stacker agent deploy-app's redeploy path uses a project_-prefixed network name that doesn't match the network the original full-stack deploy created/uses (default_network, unprefixed, per the #211 fix). The two deploy paths (stacker deploy --target cloud vs stacker agent deploy-app) appear to use inconsistent naming conventions for the same project.

Expected

stacker agent deploy-app should place the redeployed container on the same network as the rest of the project's stack (whatever the original stacker deploy created), so service-name DNS resolution keeps working.

Impact

High for the agent deploy-app workflow specifically — the command reports success but silently leaves the app unable to reach its database, with no error surfaced to the caller.

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status
    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions