How to delete interface docker0
I would like to remove the interface docker0. It would be better to avoid creating the interface docker0 when starting the service and using directly the eth0.
5 Answers 5
To delete the interface, use:
You may require sudo privilege.
docker0 network is recreated at docker daemon start. It most likely means have docker daemon enabled to auto-start. If you use docker you might not want to permanently remove the docker0 interface.
If you do want to permanently remove docker0 interface take a look at stackoverflow.com/q/52146056/72178.
By default, the Docker server creates and configures the host system’s docker0 interface as an Ethernet bridge inside the Linux kernel that can pass packets back and forth between other physical or virtual network interfaces so that they behave as a single Ethernet network.
When you install Docker, it creates three networks automatically. You can list these networks using the docker network ls command:
Historically, these three networks (bridge, none, host) are part of Docker’s implementation. When you run a container you can use the —network flag to specify which network you want to run a container on. These three networks are still available to you.
The bridge network represents the docker0 network present in all Docker installations. Unless you specify otherwise with the docker run —network= option, the Docker daemon connects containers to this network by default. You can see this bridge as part of a host’s network stack by using the ifconfig command on the host.
Экспериментальный блог
Когда-то создал ради пробы. Потом решил так и оставить.
понедельник, 20 февраля 2012 г.
Создание и удаление виртуальных сетевых интерфейсов
Понадобилось мне навесить на комп дополнительный адрес. Под виндой я просто добавляю еще один IP в свойства протокола. Под linux немного сложнее:
ifconfig ethX:Y xxx.xxx.xxx.xxx
то бишь, на реальный интерфейс ethX навершивается виртуальный ethX:Y с указанным адресом.
Всё просто и ясно, плодим виртуальные интерфейсы до посинения.
На трезвую же голову хочется их удалить, ибо уже не нужны. Радостно тычем:
и получаем «interface ethX:Y not configured«. Шикарно: адрес есть, пингуется, но не настроен. Помогает команда
которая напрочь сносит этот виртуальный интерфейс. Туда ему и дорога!
Идея найдена здесь.
(upd 20120220) Более того, такой способ считается устаревшим, и в настоящее время рекомендуется применять
$ ip addr help
Usage: ip addrIFADDR dev STRING [ LIFETIME ]
[ CONFFLAG-LIST]
ip addr del IFADDR dev STRING
ip addr[ dev STRING ] [ scope SCOPE-ID ]
[ to PREFIX ] [ FLAG-LIST ] [ label PATTERN ]
IFADDR := PREFIX | ADDR peer PREFIX
[ broadcast ADDR ] [ anycast ADDR ]
[ label STRING ] [ scope SCOPE-ID ]
SCOPE-ID := [ host | link | global | NUMBER ]
FLAG-LIST := [ FLAG-LIST ] FLAG
FLAG := [ permanent | dynamic | secondary | primary |
tentative | deprecated | CONFFLAG-LIST ]
CONFFLAG-LIST := [ CONFFLAG-LIST ] CONFFLAG
CONFFLAG := [ home | nodad ]
LIFETIME := [ valid_lft LFT ] [ preferred_lft LFT ]
LFT := forever | SECONDS
Remove network interface permanently
I’m trying to remove a network interface permanently. For some reason, ifconfig lists eth0 and eth1 , although the latter RX/TX metrics remain at zero. I suspect that extra eth1 entry might be causing delays during boot. Surprinsgly, a search did not yield any answer on how to proceed. Most posts either are for older versions of Ubuntu or Debian, or for other distros (RedHat), or have no permanent effect, or pertain to adding an interface, or try to turn it off but after it’s been started, or are simply unanswered. But the answer might be somewhere after Google’s thrid result page. Removing the second entry from the desktop (up and down arrows, on the top bar) has no effect either on ifconfig . EDIT: I actutally do have two network cards on the MB. That’s a bit of a surprise I admit. I don’t have wifi. Question still stands, a least out of curiosity.
krakoukass@durum:~$ ifconfig eth0 Link encap:Ethernet HWaddr 00:1f:d0:a3:40:d9 inet addr:192.168.1.66 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::21f:d0ff:fea3:40d9/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:84 errors:0 dropped:0 overruns:0 frame:0 TX packets:93 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:12255 (12.2 KB) TX bytes:12241 (12.2 KB) eth1 Link encap:Ethernet HWaddr 00:1f:d0:a3:40:db UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:634 errors:0 dropped:0 overruns:0 frame:0 TX packets:634 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:64758 (64.7 KB) TX bytes:64758 (64.7 KB) krakoukass@durum:~$ lspci | grep -i eth 04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 02) 05:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 02) krakoukass@durum:~$ cat /etc/network/interfaces # interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback krakoukas@durum:~$ systemctl -l status ifup@eth1.service ● ifup@eth1.service - ifup for eth1 Loaded: loaded (/lib/systemd/system/ifup@.service; static; vendor preset: enabled) Active: active (exited) since Fri 2015-05-15 12:36:34 CEST; 14min ago Process: 457 ExecStart=/bin/sh -ec ifup --allow=hotplug %I; ifup --allow=auto %I; if ifquery %I >/dev/null; then ifquery --state %I >/dev/null; fi (code=exited, status=0/SUCCESS) Main PID: 457 (code=exited, status=0/SUCCESS) May 15 12:36:34 durum systemd[1]: Started ifup for eth1. May 15 12:36:34 durum systemd[1]: Starting ifup for eth1. May 15 12:36:34 durum sh[457]: Unknown interface eth1 krakoukas@durum:~$ systemctl -l status ifup@eth0.service ● ifup@eth0.service - ifup for eth0 Loaded: loaded (/lib/systemd/system/ifup@.service; static; vendor preset: enabled) Active: active (exited) since Fri 2015-05-15 12:36:34 CEST; 15min ago Process: 458 ExecStart=/bin/sh -ec ifup --allow=hotplug %I; ifup --allow=auto %I; if ifquery %I >/dev/null; then ifquery --state %I >/dev/null; fi (code=exited, status=0/SUCCESS) Main PID: 458 (code=exited, status=0/SUCCESS) May 15 12:36:34 durum systemd[1]: Started ifup for eth0. May 15 12:36:34 durum systemd[1]: Starting ifup for eth0. May 15 12:36:34 durum sh[458]: Unknown interface eth0
How to identify orphaned veth interfaces and how to delete them?
When I start any container by docker run , we get a new veth interface. After deleting container, veth interface which was linked with container should be removed. However, sometimes it’s fail ( oftern then container started with errors):
root@hostname /home # ifconfig | grep veth | wc -l 53 root@hostname /home # docker run -d -P axibase/atsd -name axibase-atsd- 28381035d1ae2800dea51474c4dee9525f56c2347b1583f56131d8a23451a84e Error response from daemon: Cannot start container 28381035d1ae2800dea51474c4dee9525f56c2347b1583f56131d8a23451a84e: iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 33359 -j DNAT --to-destination 172.17.2.136:8883 ! -i docker0: iptables: No chain/target/match by that name. (exit status 1) root@hostname /home # ifconfig | grep veth | wc -l 55 root@hostname /home # docker rm -f 2838 2838 root@hostname /home # ifconfig | grep veth | wc -l 55
How I can identify which interfaces are linked with existing containers, and how I can remove extra interface which was linked with removed contrainers? This way doesn’t work (by root):
ifconfig veth55d245e down brctl delbr veth55d245e can't delete bridge veth55d245e: Operation not permitted
Extra interfaces now defined by transmitted traffic (if there are no activity, it’s extra interface). UPDATE
root@hostname ~ # uname -a Linux hostname 3.13.0-53-generic #89-Ubuntu SMP Wed May 20 10:34:39 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux root@hostname ~ # docker info Containers: 10 Images: 273 Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 502 Dirperm1 Supported: false Execution Driver: native-0.2 Logging Driver: json-file Kernel Version: 3.13.0-53-generic Operating System: Ubuntu 14.04.2 LTS CPUs: 8 Total Memory: 47.16 GiB Name: hostname ID: 3SQM:44OG:77HJ:GBAU:2OWZ:C5CN:UWDV:JHRZ:LM7L:FJUN:AGUQ:HFAL WARNING: No swap limit support root@hostname ~ # docker version Client version: 1.7.1 Client API version: 1.19 Go version (client): go1.4.2 Git commit (client): 786b29d OS/Arch (client): linux/amd64 Server version: 1.7.1 Server API version: 1.19 Go version (server): go1.4.2 Git commit (server): 786b29d OS/Arch (server): linux/amd64