Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to give network name in docker-compose

I am trying to create a network in docker-compose.yml

version: "3.5"
networks:
  frontend:
    name: custom_frontend
    driver: custom-driver-1

it is giving error : ERROR: The Compose file './docker-compose.yml' is invalid because: networks.frontend value Additional properties are not allowed ('name' was unexpected)

Please help

docker-compose version 1.17.1, build unknown
like image 610
raju Avatar asked Sep 29 '19 13:09

raju


People also ask

How do I specify a network in Docker?

Manage a user-defined bridgeUse the docker network create command to create a user-defined bridge network. You can specify the subnet, the IP address range, the gateway, and other options. See the docker network create reference or the output of docker network create --help for details.

What is the default network in Docker compose?

Pre-Existing Networks In this case, Docker Compose never creates the default network; instead connecting the app's containers to the i-already-created-this network.

How do I add a network to Dockerfile?

If you want to add a container to a network after the container is already running, use the docker network connect subcommand. You can connect multiple containers to the same network. Once connected, the containers can communicate using only another container's IP address or name.


1 Answers

The compose file was fine. But as jonrsharpe mentioned, your docker-compose is not support version 3.5.

The releases page

You can run the following commands to upgrade docker-compose to 1.28.5.

curl -L https://github.com/docker/compose/releases/download/1.28.5/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

(The commands were copied from the releases page)

After upgrade, you can run docker-compose -f <your-compose-file> config to check whether the compose file is valid. If your compose file is valid it'll just print it out.

like image 185
Yz. Avatar answered Oct 17 '22 14:10

Yz.