Create networks automatically in Docker Compose

Viewed 100094

When using custom networks in Docker like

networks:
  default:
    external:
      name: service-tier

And try to run that, I´m getting the error

ERROR: Network service-tier declared as external, but could not be found. Please create the network manually using docker network create service-tier and try again.

Is it possible to create networks automatically with docker-compose or is there no other way than creating them manually first?

4 Answers

I also had this error:

Network "NETWORK_NAME" needs to be recreated - option "driver" has changed
   docker network ls
   docker network rm NETWORK_NAME
   docker-compose up

After removing the problem network and recreating it, things were fine.

Run the following command: docker network create ddev_default

Related