A macvlan and a bridge Net at one Service in a Compose File

Hello,

I am trying to give a service a macvlan and a bridge network in a compose file. Something like this:

version: "3.4"
services:
  service1:
    image ..../...:latest
    --other config- volumes etc.--
    networks:
      macvlannet:
        ipv4_address: 192.168.1.54
      - bridgenet

  service2:
    image: whatever/whatever:latest
    --other config- volumes etc.--
    networks:
      - bridgenet

networks:
  macvlannet:
    name: macvlannet
    external: true
  bridgenet:
    name: bridgenet

The network configuration for Service1 generates a syntax error. I have tried several variations but nothing helped. How do I have to specify this so that it works.
If I deploy it without the second net at Service1 and afterwards connect the bridge net to Service1 it works, but only until the next deploy.

I highly recommend writing compose files in an IDE, like Visual Studio Code with the Docker extension. It would have immediacy highlighted the problem.

Though, in your case even a simple yaml linter will show the problem:

OK thanks for the reference to YAML Lint. I have now found the error. In this way it works:

  service1:
    image ..../...:latest
    --other config- volumes etc.--
    networks:
      macvlannet:
        ipv4_address: 192.168.1.54
      bridgenet:
networks:
  macvlannet:
    name: macvlannet
    external: true
  bridgenet:
    name: bridgenet