Issue - The Compose file is invalid because: Unsupported config option for web

I have the following ingnix stack that is working

web:
  image: nginx
  container_name: lab-ansred-bootstrap
  restart: unless-stopped
  volumes:
   - /volume1/docker/Bootstrap/AnsRed/config:/usr/share/nginx/html:ro
 ports:
  - "8003:80"

When I am try to use network mode to use another container as its network.

web:
  image: nginx
  container_name: lab-ansred-bootstrap
  restart: unless-stopped
  volumes:
   - /volume1/docker/Bootstrap/AnsRed/config:/usr/share/nginx/html:ro
  network_mode: "container:gluetun-Mullvad"

I get the following error

The Compose file ‘/data/compose/146/docker-compose.yml’ is invalid because: Unsupported config option for web: ‘network_mode’

I think that has to do with something related to docker compose version, not sure though what to change.

Can someone help on this please.

Hi

This should work, there is no changes in docker-compose v3 regarding this, ever :slight_smile:
But i tried to do the same as you, on my own linux pc.
Installed the latest docker-compose via Install Docker Compose | Docker Documentation

used the same docker-compose file as you, and it worked.
even tried with different types of case on the container name.

Are you running this on windows?

Hey @terpz thanks for testing

Can you share (copy and paste the stack) that worked for you here, to make sure that I don’t miss indentation or spaces or something like that.

My Setup is Synology NAS DSM, Linux

Thanks

version: '3.8'
services:
  web:
    image: nginx
    container_name: lab-ansred-bootstrap
    restart: unless-stopped
    network_mode: "container:TeST-Hest"

1 Like

@terpz that is actually worked!

There was some bad formatting/spacing in there.

THANKS FOR THE HELP!

1 Like

So what changed? because I copy pasted from you :smiley:

Yeah, these things happens most of the time with docker compose. formatting issues.

Here is the final stack that is working perfectly fine now

version: '3.8'
services:
  web:
    image: nginx
    container_name: lab-ansred-bootstrap
    restart: unless-stopped
    volumes:
    - /volume1/docker/Bootstrap/AnsRed/config:/usr/share/nginx/html:ro
    network_mode: "container:gluetun-Mullvad"

:clap: