docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.57k stars 5.18k forks source link

[BUG] NetworkMode name is not always set to a friendly name #11279

Closed alex3305 closed 9 months ago

alex3305 commented 9 months ago

Description

Whenever I deploy a stack, the Container's NetworkMode is set inconsistently. I expect it to be a friendly name set in my Compose file, but sometimes it is the network hash.

Steps To Reproduce

  1. Deploy a stack
  2. Inspect the NetworkMode attribute
  3. Notice that it is set to a hash instead of a friendly name

Compose Version

Docker Compose version v2.21.0

Docker Environment

Client: Docker Engine - Community
 Version:    24.0.7
 Context:    default
 Debug Mode: false
 Plugins:
  compose: Docker Compose (Docker Inc.)
    Version:  v2.21.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 51
  Running: 46
  Paused: 0
  Stopped: 5
 Images: 74
 Server Version: 20.10.24
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 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: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 2806fc1057397dbaeefbea0e4e17bddfbd388f38
 runc version: v1.1.5-0-gf19387a6
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 6.1.49-Unraid
 Operating System: Slackware 15.0 x86_64 (post 15.0 -current)
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 31.17GiB
 Name: LeeTower
 ID: NNGF:FSMT:LEXW:I37B:4ITD:2MKC:ORMS:LYEN:37HO:6V5O:2OY6:REJY
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

WARNING: No swap limit support

Anything else?

I have tested this with various stacks. The Owntracks stack (below) is my smallest stack that I reproduce this with.

services:
  recorder:
    container_name: owntracks_recorder
    image: owntracks/recorder
    restart: unless-stopped
    env_file: .env
    networks:
      br0:
        ipv4_address: 192.168.1.54
    environment:
      OTR_HOST: ${MQTT_HOST}
networks:
  br0:
    name: br0
    external: true

This stack deploys with a hash:

$ docker inspect -f "{{ .HostConfig.NetworkMode }}" owntracks_recorder
80c43f9f7b35a2984292ff7cf0d20db286d39ff6bb6132c1ec18a044ff5ae32d

However Immich seems to work correctly. At least for now:

$ docker inspect -f "{{ .HostConfig.NetworkMode }}" immich_server
immich
$ docker inspect -f "{{ .HostConfig.NetworkMode }}" immich_redis
immich

While my Home Assistant Compose doesn't:

$ docker inspect -f "{{ .HostConfig.NetworkMode }}" homeassistant
80c43f9f7b35a2984292ff7cf0d20db286d39ff6bb6132c1ec18a044ff5ae32d
$ docker inspect -f "{{ .HostConfig.NetworkMode }}" homeassistant_mariadb
homeassistant

And Paperless NGX and Spotweb both do work as expected.

Previously I have reported this in louislam/dockge#290 as I thought the issue was caused by that project. Since Portainer BE, which I was using before, works as expected. However even deploying from CLI I get this inconsistent behavior. Which makes me suspect that there is a bug somewhere in Compose.

alex3305 commented 9 months ago

Dupe of #11039, although I think this should still be addressed.