➜ dev-env git:(master) ✗ docker-compose -f compose/network.yml -f compose/postgres.yml up
WARNING: Some networks were defined but are not used by any service: devnev
ERROR: Service "postgres" uses an undefined network "devenv"
➜ dev-env git:(master) ✗
The main reason is probably that you misspelled “devenv” once as “devnev” in the network.yml network definition.
The following is what I wrote before I noticed the misspelled network name:
It would make more sense to just have one compose file for your service and the network definition.
If your service postgres and your network devenv do belong together, why not put them in one compose file together, like this:
If this is not what you want, then another option is to declare the network as external. That means docker will expect that network to be already existing when “executing” the compose file. Make sure to create it before, e.g. with ‘docker network create …’