Apart from simple tests in my lab, all containers I have running are started via docker-compose and thereby all configuration is kept in docker-compose YAML files.
To use the docker macvlan network created in the previous post, the following is needed:
In the global definition, define the network and set it to type external (as it is not defined in the docker compose file)
version: '3' networks: prod_net: external: true
In the service definitions, in the specific container sections, specify the network to use just like any other network
services: my-container-service-name: image: "myhandle/mycontainer" networks: - prod_net
Alternatively, if you do not want docker IPAM to assign an IP from the configured range and instead assign an IP statically (which can be outside of the configured range for IPAM:
services: my-container-service-name: image: "myhandle/mycontainer" networks: prod_net: ipv4_address: 192.168.1.202
All exposed ports on the container are exposed directly on the IP configured (by IPAM or statically) so there is no need to define ports to expose through the macvlan network. Should you want to expose services/ports through another network you will of course need to configure that accordingly.