Adding a network interface to the container 1 Run a container with default network mode # docker run --name tst_add_inf -it tst_img /bin/bash In this way, we create a container named tst_add_inf through the image tst_img on the host machine. This container has created a network interface eth0 by default. 2 Get the PID of the container # docker inspect -f '{{.State.Pid}}' tst_add_inf The PID of the container obtained above is the process PID of container process 1 in the host machine namespace. 3 Add network interface eth1 to the container (1) Create a pair of veth peer devices # ip link add veth0 type veth peer name veth1 After creation, you can see the two newly created devices through "ip link list". (2) Add the veth end to the bridge # brctl addif docker0 veth0 # ip link set veth0 up (3) Associate the other end of veth with the container # ln -s /proc/$pid/ns/net /var/run/netns/$container_id # ip link set veth1 netns $pid (4) Configure the newly added network interface of the container Rename the new interface to eth1 and change its IP address. # ip netns exec $pid ip link set dev veth1 name eth1 # ip netns exec $pid lp link set eth1 up After the container is up you can do it with "docker network connect", but that means the process is already running and might miss new ones. This question is a search on docker and multiple network interfaces. Although not the required version I leave some information here: With Docker 1.12, it is possible to add multiple network interfaces to a docker container, but you first need to create the container, then attach the second (and subsequent) network NICs before starting the container: $docker create --network=network1 --name container_name containerimage:latest $docker network connect network2 container_name $docker start container_name You need to create a network first: $docker network create --driver=bridge network1 --subnet=172.19.0.0/24 $docker network create --driver=bridge network2 --subnet=172.19.1.0/24 Additionally, you can start a container with the Dockerhost network interface by using the --network=host parameter in docker run: $docker run --net=host containerimage:latest Translated from: http://stackoverflow.com/questions/34110416/start-container-with-multiple-network-interfaces The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
>>: MySql login password forgotten and password forgotten solution
Preface This article records how I use docker-com...
1. Download from the official website and unzip h...
The difference between relative and absolute in H...
Step 1: yum install httpd -y #Install httpd servi...
Preface The effect problems used in personal actu...
1. Introduction The requirement is to obtain the ...
Download the image (optional step, if omitted, it...
1. Download the installation package Download add...
"/" is the root directory, and "~&...
This article example shares the implementation me...
Big data continues to heat up, and if you are not...
After configuring VIP, the error message that app...
CSS3 syntax: (1rem = 100px for a 750px design) @m...
1. Nested routing is also called sub-routing. In ...
1. The table tag is table, tr is row, td is cell, ...