Docker picks only one default route when attaching multiple networks and typically uses the first declared network as the default. Your macvlan network’s --gateway is ignored because the container already has a default route via the bridge network. You can either reorder networks in the Compose file so the macvlan network is primary or manually add the route to force traffic out through 192.168.31.1.