docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
34.14k stars 5.25k forks source link

Make Docker overlay network use a custom overlay network as the default for eth0 instead of the ingress network. #12323

Closed seqwait closed 4 days ago

seqwait commented 5 days ago

Description

how to Make Docker overlay network use a custom overlay network as the default for eth0 instead of the ingress network.


version: '3.8'
services:
  app:
    image: praqma/network-multitool
    environment:
      DUBBO_IP_TO_REGISTRY: "{{.Service.Name}}"
      JAVA_OPTS: "-Xms512M -Xmx2048M"
      RUN_OPTS: "--spring.profiles.active=prod --app.name=app"
    ports:
      - target: 18081
        published: 18081
        protocol: tcp
        mode: host
    volumes:
      - /etc/localtime:/etc/localtime
    networks:
      my_overall:
    deploy:
      mode: global
      placement:
        constraints:
          - "node.labels.my.app == yes"
      restart_policy:
        condition: on-failure
      update_config:
        parallelism: 1
        delay: 20s
        order: stop-first
        failure_action: rollback
      rollback_config:
        parallelism: 0
        order: stop-first

networks:
  my_overall:
    external: true
    name: my_overall
    attachable: true
ndeloof commented 5 days ago

I'm not sure I understand what you're asking for. Using a simple example:

services:
  test:
    image: alpine
    networks:
      - test

networks:
  test: {}

I can get container's eth0 to be attached to the expected network:

$ docker compose run test ifconfig
eth0      Link encap:Ethernet  HWaddr 02:42:AC:18:00:02  
          inet addr:172.24.0.2  Bcast:172.24.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:260 (260.0 B)  TX bytes:0 (0.0 B)
ndeloof commented 5 days ago

I also wonder, considering your example as a full deploy section: do you user docker compose or docker swarm ?

seqwait commented 4 days ago

I also wonder, considering your example as a full deploy section: do you user docker compose or docker swarm ?

yes, I use docker swarm , the below is ifconfig output, the eth0 connects to the ingress network , I want eth0 to use a custom overlay network (my_overall) as the default for eth0 instead of the ingress network

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
        inet 10.0.0.211  netmask 255.255.255.0  broadcast 10.0.0.255
        ether 02:42:0a:00:00:d3  txqueuelen 0  (Ethernet)
        RX packets 169  bytes 10761 (10.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
        inet 10.0.3.150  netmask 255.255.255.0  broadcast 10.0.3.255
        ether 02:42:0a:00:03:96  txqueuelen 0  (Ethernet)
        RX packets 2720860  bytes 530909731 (506.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1684984  bytes 149494365 (142.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.18.0.6  netmask 255.255.0.0  broadcast 172.18.255.255
        ether 02:42:ac:12:00:06  txqueuelen 0  (Ethernet)
        RX packets 15925583  bytes 6599924882 (6.1 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11873298  bytes 28579016117 (26.6 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 194078  bytes 14050567 (13.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 194078  bytes 14050567 (13.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
ndeloof commented 4 days ago

This repo is aout docker compose, not swarm. Please report this issue on github.com/moby/moby