In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces how to start multiple network interfaces in docker, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.
Add a network interface to the container
1 runs a container in the 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 from the mirror tst_img on the host machine, which 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 No.1 process in the host machine namespace.
3 add the network interface eth2 to the container
(1) create a pair of veth peer devices
# ip link add veth0 type veth peer name veth2
Once created, you can see the two devices you just created through "ip link list".
(2) add veth to the bridge
# brctl addif docker0 veth0# ip link set veth0 up
(3) Associate the other end of the veth with the container
# ln-s / proc/$pid/ns/net / var/run/netns/$container_id# ip link set veth2 netns $pid
(4) configure the newly added network interface of the container
Rename the new interface to eth2 and modify its IP address.
# ip netns exec $pid ip link set dev veth2 name eth2# ip netns exec $pid lp link set eth2 up
After the container starts, you can use docker network connect, but this means that the process is already running and may miss the new one.
This question is about the search of docks and multiple network interfaces. Although not the required version of some information before I leave here:
With Docker 1.12, you can add multiple network interfaces to the docker container, but you first need to create the container, and then attach a second (and subsequent) network NIC 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
In addition, you can start the container of the Dockerhost network interface using the-network = host parameter in the docker operation:
Docker run-net=host containerimage:latest on how to start multiple network interfaces in docker to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.