Skip to content

[BUG] Bake is not following the network mode in the docker-compose.yml file #12951

Closed

Description

@pmaoui

Description

Hello,

On a fresh AL2023 install, I have disabled the bridge network by having:

{
"bridge": "none"
}

docker-compose.yml:

services:
  my-server:
    container_name: my-server
    build:
      context: .
      network: host
    network_mode: host

Dockerfile:

FROM node:20.17.0

RUN apt-get update && apt-get install -y build-essential vim

When I run docker compose up:

Dockerfile:3
--------------------
   1 |     FROM node:20.17.0
   2 |
   3 | >>> RUN apt-get update && apt-get install -y build-essential vim
   4 |
--------------------
failed to solve: process "/bin/sh -c apt-get update && apt-get install -y build-essential vim" did not complete successfully: network bridge not found

Doing COMPOSE_BAKE=false docker compose up fix this issue

Steps To Reproduce

No response

Compose Version

Docker Compose version v2.37.1

Docker Environment

Client: Docker Engine - Community
 Version:    28.2.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.24.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.37.1
    Path:     /root/.docker/cli-plugins/docker-compose

Server:
 Containers: 5
  Running: 0
  Paused: 0
  Stopped: 5
 Images: 5
 Server Version: 28.2.2
 Storage Driver: overlay2
  Backing Filesystem: xfs
  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 splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05044ec0a9a75232cad458027ca83437aae3f4da
 runc version: v1.2.5-0-g59923ef
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.1.140-154.222.amzn2023.x86_64
 Operating System: Amazon Linux 2023.7.20250609
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 30.64GiB
 Name: ip-172-31-0-154.eu-central-1.compute.internal
 ID: 03ced070-dbf8-4fa8-8ce9-8728d13dc989
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: true

Anything else?

No response

Activity

  1. fritznoff commented on Jun 20, 2025

    @fritznoff

    Same here, I reproduced with this minimal example:

    docker-compose.yml:

    services:
      proxy-tester:
        build:
          context: .
          network: host
        image: my-proxy-test-image

    Dockerfile:

    FROM swisstxt/alpine-iproute2-grep:latest
    
    RUN ip addr

    With bake explicitly enabled (note the eth0 and its address):

    ❯ COMPOSE_BAKE=true docker compose --progress=plain build --no-cache
    #1 [internal] load local bake definitions
    #1 reading from stdin 675B done
    #1 DONE 0.0s
    
    #2 [internal] load build definition from Dockerfile
    #2 transferring dockerfile: 92B done
    #2 DONE 0.0s
    
    #3 [internal] load metadata for docker.io/swisstxt/alpine-iproute2-grep:latest
    #3 DONE 0.5s
    
    #4 [internal] load .dockerignore
    #4 transferring context: 2B done
    #4 DONE 0.0s
    
    #5 [1/2] FROM docker.io/swisstxt/alpine-iproute2-grep:latest@sha256:bce85b023670fed301e1758b93d2fa005c016c87ee46ff33d4436932b3be547e
    #5 CACHED
    
    #6 [2/2] RUN ip addr
    #6 0.099 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    #6 0.099     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    #6 0.099     inet 127.0.0.1/8 scope host lo
    #6 0.099        valid_lft forever preferred_lft forever
    #6 0.099     inet6 ::1/128 scope host
    #6 0.099        valid_lft forever preferred_lft forever
    #6 0.099 34: eth0@if35: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    #6 0.099     link/ether 66:6a:1f:7d:ba:d0 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    #6 0.099     inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
    #6 0.099        valid_lft forever preferred_lft forever
    #6 DONE 0.1s
    
    #7 exporting to image
    #7 exporting layers
    #7 exporting layers 0.5s done
    #7 writing image sha256:8a1bfa29e8a962b8a4b45a9de80b1276c78a272c3120dafd1249d39676d4c380
    #7 writing image sha256:8a1bfa29e8a962b8a4b45a9de80b1276c78a272c3120dafd1249d39676d4c380 done
    #7 naming to docker.io/library/my-proxy-test-image done
    #7 DONE 0.5s
    
    #8 resolving provenance for metadata file
    #8 DONE 0.0s
     proxy-tester  Built

    With bake explicitly enabled (note the host's interfaces):

    ❯ COMPOSE_BAKE=false docker compose --progress=plain build --no-cache
    #0 building with "default" instance using docker driver
    
    #1 [proxy-tester internal] load build definition from Dockerfile
    #1 transferring dockerfile: 92B done
    #1 DONE 0.0s
    
    #2 [proxy-tester internal] load metadata for docker.io/swisstxt/alpine-iproute2-grep:latest
    #2 DONE 0.5s
    
    #3 [proxy-tester internal] load .dockerignore
    #3 transferring context: 2B done
    #3 DONE 0.0s
    
    #4 [proxy-tester 1/2] FROM docker.io/swisstxt/alpine-iproute2-grep:latest@sha256:bce85b023670fed301e1758b93d2fa005c016c87ee46ff33d4436932b3be547e
    #4 CACHED
    
    #5 [proxy-tester 2/2] RUN ip addr
    #5 0.044 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    #5 0.044     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    #5 0.044     inet 127.0.0.1/8 scope host lo
    #5 0.044        valid_lft forever preferred_lft forever
    #5 0.044 2: enp0s31f6: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    #5 0.044     link/ether <omitted> brd ff:ff:ff:ff:ff:ff
    #5 0.044     altname enx4cd717660e40
    #5 0.044 3: enp0s13f0u1u1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    #5 0.044     link/ether a0:ce:c8:ed:6d:4f brd ff:ff:ff:ff:ff:ff
    #5 0.044     altname enxa0cec8ed6d4f
    #5 0.044 4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    #5 0.044     link/ether <omitted> brd ff:ff:ff:ff:ff:ff
    #5 0.044     inet 10.1.2.3/24 brd 10.1.2.255 scope global dynamic noprefixroute wlan0
    #5 0.044        valid_lft 83037sec preferred_lft 83037sec
    #5 0.044        valid_lft forever preferred_lft forever
    #5 0.044 7: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    #5 0.044     link/ether 32:9a:7c:ac:39:f8 brd ff:ff:ff:ff:ff:ff
    #5 0.044     inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
    #5 0.044        valid_lft forever preferred_lft forever
    #5 DONE 0.1s
    
    #6 [proxy-tester] exporting to image
    #6 exporting layers 0.0s done
    #6 writing image sha256:bc2b1aa1ef14640f552fff8eecbde31a0c784c6206e46953bff79b6cb37899ff done
    #6 naming to docker.io/library/my-proxy-test-image done
    #6 DONE 0.0s
    
    #7 [proxy-tester] resolving provenance for metadata file
    #7 DONE 0.0s
     proxy-tester  Built

    Version info:

    ❯ docker compose version
    Docker Compose version 2.37.1
    ❯ docker info
    Client:
     Version:    28.2.2
     Context:    default
     Debug Mode: false
     Plugins:
      buildx: Docker Buildx (Docker Inc.)
        Version:  0.25.0
        Path:     /usr/lib/docker/cli-plugins/docker-buildx
      compose: Docker Compose (Docker Inc.)
        Version:  2.37.1
        Path:     /usr/lib/docker/cli-plugins/docker-compose
    
    Server:
     Containers: 7
      Running: 0
      Paused: 0
      Stopped: 7
     Images: 67
     Server Version: 28.2.2
     Storage Driver: overlay2
      Backing Filesystem: extfs
      Supports d_type: true
      Using metacopy: true
      Native Overlay Diff: false
      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 splunk syslog
     CDI spec directories:
      /etc/cdi
      /var/run/cdi
     Swarm: inactive
     Runtimes: io.containerd.runc.v2 runc
     Default Runtime: runc
     Init Binary: docker-init
     containerd version: 64ed272067a24c2d917064eea25a78e1479d632f.m
     runc version:
     init version: de40ad0
     Security Options:
      seccomp
       Profile: builtin
      cgroupns
     Kernel Version: 6.15.2-arch1-1
     Operating System: Arch Linux
     OSType: linux
     Architecture: x86_64
     CPUs: 20
     Total Memory: 62.48GiB
     Name: <omitted>
     ID: 3dcf1c7d-f653-4634-8a7f-d377c4b0d004
     Docker Root Dir: /var/lib/docker
     Debug Mode: false
     HTTP Proxy: http://127.0.0.1:9000/
     HTTPS Proxy: http://127.0.0.1:9000/
     No Proxy: <omitted>
     Experimental: false
     Insecure Registries:
      ::1/128
      127.0.0.0/8
     Live Restore Enabled: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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