docker / for-linux

Docker Engine for Linux
https://docs.docker.com/engine/installation/
756 stars 85 forks source link

Two containers with same network can NOT ping each other #723

Open jacobcnca opened 5 years ago

jacobcnca commented 5 years ago

Two containers with same network can't ping each other

I try to connect a network to a container, I removed the IP address for the bridge interface before connect. And after connect to the container, the bridge interface bring down.

Expected behavior

Actual behavior

Two containers can NOT ping each other with same network.

And it work well after run ifconfig tt up manually.

Steps to reproduce the behavior

  1. Create a network
    $ docker network create -o "com.docker.network.bridge.name"="tt" test
  2. Create a container
    $ docker run -it -d ubuntu /bin/sh
    449xxxxxxxxxxxxxxxx
  3. Remove IP address from the bridge interface
    $ ifconfig tt 0.0.0.0

    check the interface state

  4. Connect the network to the container
    $ docker network connect test 449

    Check the interface state again

Output of docker version:

$ docker version
Client:
 Version:           18.09.6
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        481bc77
 Built:             Sat May  4 02:35:27 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.6
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       481bc77
  Built:            Sat May  4 01:59:36 2019
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker info:

Containers: 1
 Running: 1
 Paused: 0
 Stopped: 0
Images: 61
Server Version: 18.09.6
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: bb71b10fd8f58240ca47fbb579b9d1028eea7c84
runc version: 2b18fe1d885ee5083ef9f0838fee39b62d653e30
init version: fec3683
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.15.0-54-generic
Operating System: Ubuntu 16.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 24
Total Memory: 62.9GiB
Name: R710
ID: YI3J:AA2Y:F5LF:TUNC:SPSS:TZSV:OL4N:IX4B:WF4Z:XQ4K:RTOH:7PZK
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 registry.example.net:5000
 127.0.0.0/8
Registry Mirrors:
 http://f1361db2.m.daocloud.io/
Live Restore Enabled: false
Product License: Community Engine

WARNING: No swap limit support

Additional environment details (AWS, VirtualBox, physical, etc.)

Relate syslog

############################## Create the network #########################
Jul  9 15:28:58 R710 NetworkManager[1430]: <info>  [1562657338.3870] manager: (tt): new Bridge device (/org/freedesktop/NetworkManager/Devices/3325)
Jul  9 15:28:58 R710 NetworkManager[1430]: <info>  [1562657338.3989] devices added (path: /sys/devices/virtual/net/tt, iface: tt)
Jul  9 15:28:58 R710 NetworkManager[1430]: <info>  [1562657338.3989] device added (path: /sys/devices/virtual/net/tt, iface: tt): no ifupdown configuration found.
Jul  9 15:28:58 R710 kernel: [89008.728995] IPv6: ADDRCONF(NETDEV_UP): tt: link is not ready
Jul  9 15:28:58 R710 avahi-daemon[1440]: Joining mDNS multicast group on interface tt.IPv4 with address 172.28.0.1.
Jul  9 15:28:58 R710 avahi-daemon[1440]: New relevant interface tt.IPv4 for mDNS.
Jul  9 15:28:58 R710 avahi-daemon[1440]: Registering new address record for 172.28.0.1 on tt.IPv4.
Jul  9 15:28:58 R710 NetworkManager[1430]: <info>  [1562657338.4151] device (tt): state change: unmanaged -> unavailable (reason 'connection-assumed') [10 20 41]
Jul  9 15:28:58 R710 NetworkManager[1430]: <info>  [1562657338.4171] keyfile: add connection in-memory (dbdc696b-7a09-4785-a6be-b5f8e5cadb93,"tt")
Jul  9 15:28:58 R710 NetworkManager[1430]: <info>  [1562657338.4188] device (tt): state change: unavailable -> disconnected (reason 'connection-assumed') [20 30 41]
Jul  9 15:28:58 R710 NetworkManager[1430]: <info>  [1562657338.4200] device (tt): Activation: starting connection 'tt' (dbdc696b-7a09-4785-a6be-b5f8e5cadb93)
Jul  9 15:28:58 R710 NetworkManager[1430]: <info>  [1562657338.4205] device (tt): state change: disconnected -> prepare (reason 'none') [30 40 0]
Jul  9 15:28:58 R710 NetworkManager[1430]: <info>  [1562657338.4210] device (tt): state change: prepare -> config (reason 'none') [40 50 0]
Jul  9 15:28:58 R710 NetworkManager[1430]: <info>  [1562657338.4213] device (tt): state change: config -> ip-config (reason 'none') [50 70 0]
Jul  9 15:28:58 R710 NetworkManager[1430]: <info>  [1562657338.4272] device (tt): state change: ip-config -> ip-check (reason 'none') [70 80 0]
Jul  9 15:28:58 R710 NetworkManager[1430]: <info>  [1562657338.4280] device (tt): state change: ip-check -> secondaries (reason 'none') [80 90 0]
Jul  9 15:28:58 R710 NetworkManager[1430]: <info>  [1562657338.4283] device (tt): state change: secondaries -> activated (reason 'none') [90 100 0]
Jul  9 15:28:58 R710 NetworkManager[1430]: <info>  [1562657338.4323] device (tt): Activation: successful, device activated.
Jul  9 15:28:58 R710 nm-dispatcher: req:1 'up' [tt]: new request (1 scripts)
Jul  9 15:28:58 R710 nm-dispatcher: req:1 'up' [tt]: start running ordered scripts...

 ############################# Remove the IP address ######################## 
Jul  9 15:29:09 R710 avahi-daemon[1440]: Withdrawing address record for 172.28.0.1 on tt.
Jul  9 15:29:09 R710 avahi-daemon[1440]: Leaving mDNS multicast group on interface tt.IPv4 with address 172.28.0.1.
Jul  9 15:29:09 R710 avahi-daemon[1440]: Interface tt.IPv4 no longer relevant for mDNS.

######################### Connect network to the container #####################
Jul  9 15:29:33 R710 kernel: [89043.734597] tt: port 1(veth70904fd) entered blocking state
Jul  9 15:29:33 R710 kernel: [89043.734600] tt: port 1(veth70904fd) entered disabled state
Jul  9 15:29:33 R710 kernel: [89044.195153] tt: port 1(veth70904fd) entered blocking state
Jul  9 15:29:33 R710 kernel: [89044.195155] tt: port 1(veth70904fd) entered forwarding state
Jul  9 15:29:33 R710 kernel: [89044.195221] IPv6: ADDRCONF(NETDEV_CHANGE): tt: link becomes ready
Jul  9 15:29:33 R710 NetworkManager[1430]: <info>  [1562657373.8856] device (tt): link connected
Jul  9 15:29:33 R710 NetworkManager[1430]: <info>  [1562657373.8857] device (tt): state change: activated -> unmanaged (reason 'connection-assumed') [100 10 41]
Jul  9 15:29:33 R710 kernel: [89044.206876] tt: port 1(veth70904fd) entered disabled state
Jul  9 15:29:33 R710 kernel: [89044.210100] IPv6: ADDRCONF(NETDEV_UP): tt: link is not ready
Jul  9 15:29:33 R710 nm-dispatcher: req:1 'down' [tt]: new request (1 scripts)
Jul  9 15:29:33 R710 nm-dispatcher: req:1 'down' [tt]: start running ordered scripts...
Jul  9 15:29:33 R710 NetworkManager[1430]: <info>  [1562657373.9189] device (tt): link disconnected
trelljaret commented 4 years ago

I had the same problem. The problem is because of using docker snappy inside ubuntu. Dont use docker from snap. It just sucks. Install it from the official source: https://docs.docker.com/engine/install/ubuntu/

trelljaret commented 4 years ago

Actually I reinstalled from offical source. Still having the same problem :(

trelljaret commented 4 years ago

The problem was from not having enough memory. Added 2GB swap file and the problem is gone. https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-18-04/