Unsupported config option for services.networks: 'my_network'
Asked Answered
N

2

8

I am having below error while running the docker-compose file. I have created a bridge network with name my_network

Unsupported config option for services.networks: 'my_network'

docker-compose.yml

version: '3.3'
services:
  webapp1:
    image: nginx:latest
    container_name: my_container
    ports:
      - "8080:8080"
    networks:
      - my_network
    volumes:
      - /home/ajay/nginx:/www/data
Naranjo answered 9/7, 2020 at 23:55 Comment(1)
Did you create the network and want to attach the services to it?Trentontrepan
S
3

That seems docker-compose configuration issue, use below docker-compose file, it will create a network and then you can use the same network in the docker-compose file.

version: '3.5'

services:
  webapp1:
    image: nginx:latest
    container_name: my_container
    ports:
      - "8080:80"
    networks:
      - my_network

networks:
  my_network:
    driver: bridge

Also Nginx port should be 80 inside the container if you did not modify the default configuration.

Superorder answered 10/7, 2020 at 0:27 Comment(0)
C
0

If you see this message, it may be because there is a space before "networks:". Because YAML is space sensitive.

Crankshaft answered 30/7 at 8:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.