Docker Compose networkid change

Hello All,
I have an issue with one stack when I try to compose up it after restarting the docker service itself.
In the compose file I have referenced an external network :
name: br0
external: true

I used it on two services in order to fix the ip of both container.

Unfortunately, as soon as I restart the docker service, I can’t restart the containers because the network_id is not available anymore.

I made some research and I found this :
If I create the containers using docker compose :

  • The HostConfig:network_mode is set with the networkid of the referenced network name at the time of the creation of the container.
  • I restart the docker service
  • Then the networkId has changed leading to a failure to start both containers. They are referencing the old network id. In order to solve It I need to update the stack and recreate both container.

If I create the containers using docker run (with --net=br0 and --ip=)

  • The HostConfig:network_mode is set to br0
  • I restart the docker service
  • Both containers restart fine because they are referencing the network by its name not its ID which is subject to be change.

Is it a normal situation ?
Can I change something on my compose in order to solve this issue ?

Thanks for your help,
Best regards,
Damien T.