0

I want to start a docker container with three interfaces, all these interfaces will be attached to a bridge on host. The only solution is providing my own network plugin. the below interface will be invoked by docker daemon once container is created to configure its network:

func (d *Driver) Join(r *dknet.JoinRequest) (*dknet.JoinResponse, error)

but there is only one Endpoint object in JoinRequest struct, so the above invocation can only configure one container interface.

I don't know how to create and configure three container interfaces?

1 Answer 1

1

You need to do it multiple time

$ docker network create net1
bdc53c143e89d562761eedfd232620daf585968bc9ae022ba142d17601af6146

$ docker network create net2
d9a72a7a6ee6b61da3c6bb17e312e48888807a5a8c159fd42b6c99d219977559

$ docker network create net3
d2be9628f4fd60587d44967a5813e9ba7c730d24e953368b18d7872731a9478c

$ docker run -it --network net3 ubuntu:16.04 bash

root@cd70c7cbe367:/# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
90: eth0@if91: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:ac:18:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.24.0.2/16 scope global eth0
       valid_lft forever preferred_lft forever

Now your container is running with net3 network only. You can attach net1 and net2 as well.

$ docker network connect net1 cd70c7cbe367
$ docker network connect net2 cd70c7cbe367

After that check in container

root@cd70c7cbe367:/# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
90: eth0@if91: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:ac:18:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.24.0.2/16 scope global eth0
       valid_lft forever preferred_lft forever
92: eth1@if93: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:ac:16:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.22.0.2/16 scope global eth1
       valid_lft forever preferred_lft forever
94: eth2@if95: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:ac:17:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.23.0.2/16 scope global eth2
       valid_lft forever preferred_lft forever

PS: the ip command is missing by default in container, so i installed the iproute2 packaged to check

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.