1

Let me re-organised the question. I have used a similar docker-compose yaml file as below.

version: "3"
services:
  app:
    build: ./app
    networks:
      - frontend
 
networks:
  frontend:
     driver: bridge
     ipam:
       config:
         - subnet: 172.38.3.0/24

A network interface eth0 will be created automatically inside the dock container APP. I can connect to the network of the host through eth0.

Now I want to create other virtual network interfaces inside the docker container APP, such as veth1, veth2. I want to let the packets through veth1/veth2 can access the host network. Like the below,

ping -I veth1 host-network-ip

by the way, I have tried to define one more network in the yaml and attached to docker container APP. but unfortunately, the network interface name eth1 inside docker container could not be customized. I need to specify the network interface name.

Is it possible to let it work? if yes, can you please help to explain how to do? Thank you very much!

3
  • 1
    There's LOTS of iptables stuff inside the containers, so even if you add veth pairs, I'd doubt it would work well. Instead, consider using custom networks in your docker compose file. (You didn't describe your actual use case, see XY questions, but chances your original problem X can be solved through this are high).
    – dirkt
    Commented Jul 5, 2020 at 9:36
  • @dirkt Thank you very much for your reply. I have updated my question. Hope it's more clear now. I have tried to define one more network in docker-compose yaml, but it could not specify the network interface name inside docker container.
    – jackion
    Commented Jul 7, 2020 at 0:59
  • You still have not explained why you want different network interfaces, and why you want to access the host network. What is your use case? Is something on the host running you want to access? Do you want extra filtering on the network interfaces? What do you hope to gain from doing it this way, instead of following the docker model and exposing ports for services to the outside world, and letting services within containers communicate with each other?
    – dirkt
    Commented Jul 7, 2020 at 4:12

0

You must log in to answer this question.

Browse other questions tagged .