Skip to content

[BUG] watch throws "Application failed to start after update" if an external network exists on the container it is trying to rebuild #11081

@kimdcottrell

Description

@kimdcottrell

Description

When you edit .env, the watch command will error out with: Application failed to start after update.

Ideally, it would rebuild and, well, not care about the external network.

The behavior is actually quite problematic, as reverse proxies and their external networks are commonly used to enable https for local development.

Steps To Reproduce

If your docker-compose.yml looks something like this:

version: "3.9"

services:
  leads:
    build:
      context: .
      dockerfile: images/leads.Dockerfile
    develop:
      watch:
        - action: rebuild
          path: .env
    env_file:
      - .env
    volumes:
      - ./leads:/leads
    working_dir: /leads
    labels:
      - traefik.enable=true
      - traefik.http.middlewares.leads-carrierami-redirect-web-secure.redirectscheme.scheme=https
      - traefik.http.routers.leads-carrierami.middlewares=leads-carrierami-redirect-web-secure
      - traefik.http.routers.leads-carrierami-web.rule=Host(`leads.carrierami.dev`)
      - traefik.http.routers.leads-carrierami-web.entrypoints=web
      - traefik.http.routers.leads-carrierami-web-secure.rule=Host(`leads.carrierami.dev`)
      - traefik.http.routers.leads-carrierami-web-secure.tls=true
      - traefik.http.routers.leads-carrierami-web-secure.entrypoints=web-secure
      # if you have multiple ports exposed on the service, specify port in the web-secure service
      - traefik.http.services.leads-carrierami-web-secure.loadbalancer.server.port=5173
    networks:
      - proxy # this is the necessary bug-inducting setting


networks:
  proxy:
    name: proxy # this can be left out, the error will still persist
    external: true

I pulled down compose from the repo and have been running make install to pin this down. I'm new-ish to golang, so it's been a lot of fmt.Print statements. With that said, if you edit here:

fmt.Fprintf(s.stderr(), "Application failed to start after update\n")
to include the err, you get this:

%!(EXTRA *errors.errorString=network 812cf22efd847adccaa1f0f20f22e82194cff4267ee8fcb6bc2bbe5233f95108 declared as external, but could not be found)

Output of docker network ls is:

NETWORK ID     NAME                 DRIVER    SCOPE
6297c2407a95   bridge               bridge    local
8744c8b5d82f   carrierami_default   bridge    local
f2575fd23622   host                 host      local
1cea7b252534   localproxy_default   bridge    local
4777c363fe9a   none                 null      local
812cf22efd84   proxy                bridge    local
6a3741a5a94a   techlab_default      bridge    local

A docker network inspect proxy gives me:

docker network inspect proxy
[
    {
        "Name": "proxy",
        "Id": "812cf22efd847adccaa1f0f20f22e82194cff4267ee8fcb6bc2bbe5233f95108",
        "Created": "2023-10-10T13:22:57.630807544-04:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "71b7a38638cc4ed92c7a728874146866835d450f1f2af95dcd00ad6776c2180e": {
                "Name": "carrierami-app-1",
                "EndpointID": "a35e104840b99c4739cfc5488c420c14d3d2ce65f4f4fde6c0e1e3143631dc53",
                "MacAddress": "02:42:ac:13:00:04",
                "IPv4Address": "172.19.0.4/16",
                "IPv6Address": ""
            },
            "72440defdc1060dc6a5818a31c6f8fb3b3d947dfa333d4de5bfdce33436ed2e9": {
                "Name": "carrierami-api-1",
                "EndpointID": "7c3a643df5a81ad06d1e2dcc4a5680b0eeb0906c2d977e4c0ad07d620bcaf395",
                "MacAddress": "02:42:ac:13:00:03",
                "IPv4Address": "172.19.0.3/16",
                "IPv6Address": ""
            },
            "d4c3421e0f956ff838efbdb557b76c464debf3e4ac86f0f61b0057b111e365e1": {
                "Name": "localproxy-whoami-1",
                "EndpointID": "625f371abdb2d835712d757b45986fa59fd9ce4cf5d9061379391af9166a3e42",
                "MacAddress": "02:42:ac:13:00:07",
                "IPv4Address": "172.19.0.7/16",
                "IPv6Address": ""
            },
            "e9bb5c0ac6ad103ab2dd523aae91bcf613ec56cb6b9d185f5d7f2d0eb223d730": {
                "Name": "carrierami-leads-1",
                "EndpointID": "46a7f632472af15af2f163bf26f6a5f10b2f73e1a6d94bc845ecc8514baaf254",
                "MacAddress": "02:42:ac:13:00:05",
                "IPv4Address": "172.19.0.5/16",
                "IPv6Address": ""
            },
            "e9e3e49908f4d30a063ce321ae3b62a044530a2f63836c4262a6880f7888b863": {
                "Name": "carrierami-persistent_db_adminer-1",
                "EndpointID": "c5c7bcb02c7037204aff0beecd2b932ba8113c04830993b13a92ddefd1e96bee",
                "MacAddress": "02:42:ac:13:00:02",
                "IPv4Address": "172.19.0.2/16",
                "IPv6Address": ""
            },
            "ed3e5ccd18407b763f17cf7a6c4555d079bffd4bb90987219585cb31ca130a92": {
                "Name": "localproxy-traefik-1",
                "EndpointID": "1c1f9139d18ba65c401a0125d20b166a77d070a302eef20516c6bbab9e12283c",
                "MacAddress": "02:42:ac:13:00:06",
                "IPv4Address": "172.19.0.6/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "proxy",
            "com.docker.compose.project": "localproxy",
            "com.docker.compose.version": "2.22.0"
        }
    }
]

So the network definitely exists, it's external to this application, just watch chokes on rebuild as soon as the create tries to work with it.

Compose Version

Docker Compose version v2.22.0-15-g9dd081b9.m

Docker Environment

Client: Docker Engine - Community
 Version:    24.0.6
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.22.0-15-g9dd081b9.m
    Path:     /home/kim/.docker/cli-plugins/docker-compose

Server:
 Containers: 11
  Running: 9
  Paused: 0
  Stopped: 2
 Images: 13
 Server Version: 24.0.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 61f9fd88f79f081d64d6fa3bb1a0dc71ec870523
 runc version: v1.1.9-0-gccaecfc
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  userns
  cgroupns
 Kernel Version: 6.2.12-060212-generic
 Operating System: Ubuntu 23.04
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 31.11GiB
 Name: kimtalkstech
 ID: 0a5d9854-6123-4f75-abb0-5bc3146faeb6
 Docker Root Dir: /var/lib/docker/1000.1000
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

Please buy the team who made watch a cake. I have been building Dockerized localdevs for work and for fun for years now and this is the coolest thing. <3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions