New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composefile v2 & default bridge network ERROR: b'Network-scoped alias is supported only for containers in user defined networks' #3012

Closed
niko opened this Issue Feb 24, 2016 · 14 comments

Comments

Projects
None yet
10 participants
@niko

niko commented Feb 24, 2016

When using composefile version 2 with the default bridge network this error occurs:

$ docker-compose up
Creating dockercomposetest_debian_1
ERROR: b'Network-scoped alias is supported only for containers in user defined networks'

This is my docker-compose.yml:

version: '2'

services:
  debian:
    image: debian:wheezy

networks:
  default:
    external:
      name: bridge

I'm using compose 1.6.0 and docker 1.10.1.

@dnephin

This comment has been minimized.

Show comment
Hide comment
@dnephin

dnephin Feb 24, 2016

Contributor

To use the bridge network use network_mode: https://docs.docker.com/compose/compose-file/#network-mode

Compose relies on network scoped aliases, so if you try to use bridge as an external network it will set those aliases. If you use network_mode, it will disable the built-in aliases, and rely on the aliases made available by the bridge network.

Contributor

dnephin commented Feb 24, 2016

To use the bridge network use network_mode: https://docs.docker.com/compose/compose-file/#network-mode

Compose relies on network scoped aliases, so if you try to use bridge as an external network it will set those aliases. If you use network_mode, it will disable the built-in aliases, and rely on the aliases made available by the bridge network.

@niko

This comment has been minimized.

Show comment
Hide comment
@niko

niko Feb 26, 2016

Thanks! Works like a charm!

niko commented Feb 26, 2016

Thanks! Works like a charm!

@sabberworm

This comment has been minimized.

Show comment
Hide comment
@sabberworm

sabberworm May 4, 2016

@dnephin Is it possible to join both the bridge external network and other networks at the same time? It seems it should be possible but when I do it like the OP I get the error mentioned and when I use network_mode: bridge I get:

ERROR: 'network_mode' and 'networks' cannot be combined

sabberworm commented May 4, 2016

@dnephin Is it possible to join both the bridge external network and other networks at the same time? It seems it should be possible but when I do it like the OP I get the error mentioned and when I use network_mode: bridge I get:

ERROR: 'network_mode' and 'networks' cannot be combined

@ninchan8328

This comment has been minimized.

Show comment
Hide comment
@ninchan8328

ninchan8328 May 16, 2016

Would also like to know if a container can join a default bridge network as a external network and a custom network at the same time. Please help!

ninchan8328 commented May 16, 2016

Would also like to know if a container can join a default bridge network as a external network and a custom network at the same time. Please help!

@ninchan8328

This comment has been minimized.

Show comment
Hide comment
@ninchan8328

ninchan8328 May 16, 2016

I figured out, i can have the docker-compose to start the container in a custom network and then do a docker network connect bridge [container] to join the default network that way.

ninchan8328 commented May 16, 2016

I figured out, i can have the docker-compose to start the container in a custom network and then do a docker network connect bridge [container] to join the default network that way.

@prologic

This comment has been minimized.

Show comment
Hide comment
@prologic

prologic Jun 4, 2016

I'm also trying to find a way to connect a service to the default bridge network and it's own. @niko ninchan8328 How did you end up doing this? Is there a way to easily do both?

prologic commented Jun 4, 2016

I'm also trying to find a way to connect a service to the default bridge network and it's own. @niko ninchan8328 How did you end up doing this? Is there a way to easily do both?

@allamand

This comment has been minimized.

Show comment
Hide comment
@allamand

allamand Jun 6, 2016

regarding this message ERROR: 'network_mode' and 'networks' cannot be combined is there a way for a container to access both user defined overlay networks & physical external network such as host or bridge ?

allamand commented Jun 6, 2016

regarding this message ERROR: 'network_mode' and 'networks' cannot be combined is there a way for a container to access both user defined overlay networks & physical external network such as host or bridge ?

@ninchan8328

This comment has been minimized.

Show comment
Hide comment
@ninchan8328

ninchan8328 Jun 6, 2016

@prologic the way i do is to have the docker-compose spin up the container in its network, then use the docker network connect command to assign the container to different network as needed. I don't think you can do the default bridge and dedicated network at the same time in the compose file but I could be wrong

ninchan8328 commented Jun 6, 2016

@prologic the way i do is to have the docker-compose spin up the container in its network, then use the docker network connect command to assign the container to different network as needed. I don't think you can do the default bridge and dedicated network at the same time in the compose file but I could be wrong

@prologic

This comment has been minimized.

Show comment
Hide comment
@prologic

prologic Jun 7, 2016

@ninchan8328 Ahh I see. This sounds like a very good use case for a new autodock plugin say autodock-network-attach whose sole responsibility is to listen to started events for any container that have an environment NETWORK_ATTACH=<network1,network2,networkN> for a list of networks to attach to after being brought up.

I'll implement this tonight; because it'll mean that I don't have to use network_mode: "bridge" in many of my services and explicitly attach the ones that need attaching to the "bridge" network :)

prologic commented Jun 7, 2016

@ninchan8328 Ahh I see. This sounds like a very good use case for a new autodock plugin say autodock-network-attach whose sole responsibility is to listen to started events for any container that have an environment NETWORK_ATTACH=<network1,network2,networkN> for a list of networks to attach to after being brought up.

I'll implement this tonight; because it'll mean that I don't have to use network_mode: "bridge" in many of my services and explicitly attach the ones that need attaching to the "bridge" network :)

grayside pushed a commit to phase2/generator-outrigger-drupal that referenced this issue Jun 5, 2017

Chris Johnson
Set a network_mode of bridge for all services
Without setting a network_mode of bridge docker-compose starting with
version 2 of the api will start creating a network automatically based
on a scheme of [projectname]_default. This network appears to take an
incrementing IP address range (so the first one is 172.18.* after the
172.17.* taken by the bridge network). The network routing devtools
sets up doesn't work for ranges outside of 172.17.* so while containers
can talk to each other they can't be chatted with from the outside.

See also:
  docker/compose#3012
  https://docs.docker.com/compose/compose-file/#network-mode
  https://docs.docker.com/compose/networking/
@sueastside

This comment has been minimized.

Show comment
Hide comment
@sueastside

sueastside Jun 14, 2017

My current workaround for joining the bridge network and the default compose created one:

version: '3'
services:
  multi-network-service
    image: ubuntu
    labels:
       - networks=bridge
  connect-bridge:
    image: stmllr/docker-client
    volumes:
     - /var/run/docker.sock:/var/run/docker.sock:ro
    depends_on:
       - multi-network-service
    command: /bin/sh -c 'docker ps -f label=networks=bridge --format "{{.ID}}" | xargs docker network connect bridge'

Which gives me:

"Networks": {
    "bridge": {
        ...
    },
    "test_default": {
        "Aliases": [
            "multi-network-service",
            "a579a8c514ff"
        ],
        ...
    }
}

sueastside commented Jun 14, 2017

My current workaround for joining the bridge network and the default compose created one:

version: '3'
services:
  multi-network-service
    image: ubuntu
    labels:
       - networks=bridge
  connect-bridge:
    image: stmllr/docker-client
    volumes:
     - /var/run/docker.sock:/var/run/docker.sock:ro
    depends_on:
       - multi-network-service
    command: /bin/sh -c 'docker ps -f label=networks=bridge --format "{{.ID}}" | xargs docker network connect bridge'

Which gives me:

"Networks": {
    "bridge": {
        ...
    },
    "test_default": {
        "Aliases": [
            "multi-network-service",
            "a579a8c514ff"
        ],
        ...
    }
}
@Wilfred

This comment has been minimized.

Show comment
Hide comment
@Wilfred

Wilfred Jun 20, 2017

For future reference, the docs for network_mode are here: https://docs.docker.com/compose/compose-file/#network_mode (there seems to be a website bug that prevents browsers scrolling to #network_mode, but it is on that page)

The configuration provided by the bug reporter:

version: '2'

services:
  debian:
    image: debian:wheezy

networks:
  default:
    external:
      name: bridge

Should be:

version: '2'

services:
  debian:
    image: debian:wheezy
    network_mode: bridge

Wilfred commented Jun 20, 2017

For future reference, the docs for network_mode are here: https://docs.docker.com/compose/compose-file/#network_mode (there seems to be a website bug that prevents browsers scrolling to #network_mode, but it is on that page)

The configuration provided by the bug reporter:

version: '2'

services:
  debian:
    image: debian:wheezy

networks:
  default:
    external:
      name: bridge

Should be:

version: '2'

services:
  debian:
    image: debian:wheezy
    network_mode: bridge
@prologic

This comment has been minimized.

Show comment
Hide comment
@prologic

prologic Jul 1, 2017

@Wilfred This doesn't work for docker stack deploy ...:

Ignoring unsupported options: network_mode

prologic commented Jul 1, 2017

@Wilfred This doesn't work for docker stack deploy ...:

Ignoring unsupported options: network_mode
@NullVoxPopuli

This comment has been minimized.

Show comment
Hide comment
@NullVoxPopuli

NullVoxPopuli Apr 19, 2018

I have an issue where I can network two images together via docker but not docker-compose.

I've asked about it here: https://groups.google.com/forum/#!topic/drools-setup/VvYVh1GWFps
but maybe you guys know the answer, since this github issue is directly related to my problem.

what I need, is for 2 compose services to use the same network as the default network used by regular docker commands.

Edit:

using the above network_mode: bridge fixes my problem!

NullVoxPopuli commented Apr 19, 2018

I have an issue where I can network two images together via docker but not docker-compose.

I've asked about it here: https://groups.google.com/forum/#!topic/drools-setup/VvYVh1GWFps
but maybe you guys know the answer, since this github issue is directly related to my problem.

what I need, is for 2 compose services to use the same network as the default network used by regular docker commands.

Edit:

using the above network_mode: bridge fixes my problem!

@hmdshariati

This comment has been minimized.

Show comment
Hide comment
@hmdshariati

hmdshariati Jun 24, 2018

How to choose Static with network_mode: bridge

hmdshariati commented Jun 24, 2018

How to choose Static with network_mode: bridge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment