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
When making a web page, you sometimes use a dividi...
Execute the following command to report an error ...
Install MySQL 8.0 docker run -p 63306:3306 -e MYS...
Anyone who has worked on a large system knows tha...
eureka: 1. Build a JDK image Start the eureka con...
Table of contents 1. Content Overview 2. Concepts...
Table of contents Preface 1. How to write functio...
Sorting Problem I recently read "45 Lectures...
Set the width of the body to the width of the wind...
1. Native network request 1. XMLHttpRequest (w3c ...
The mysql 5.7.18 zip version of MySQL is not like...
Create a project Create a project in WeChat Devel...
I finished learning SQL by myself not long ago, a...
We know that the commonly used events in JS are: ...
Here we mainly use spring-boot out of the box, wh...