moby / moby/libnetwork

same ip for different containers in bridge network

Open
#1,740 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
2.2k
Forks
875
PR merge metrics
No merged PRs in 30d

Description

Description
Two different containers use same ip in bridge network at the same time.
Sometimes two containers use same ip.


Steps to reproduce the issue
use a simple script, create a lots of containers at the same time. use python script:

import multiprocessing
import subprocess

def create(_=None):
    p = subprocess.check_output("docker run -it --rm busybox sleep 1200", shell=True)

def main():
    p_nums = 600
    p = multiprocessing.Pool(p_nums)
    p.map(create, range(p_nums))

if __name__ == "__main__":
    main()

run this script, then check all containers ip.


Describe the results you received
one container:

liutianwei@jolly2 ~ $ docker inspect suspicious_allen
[
    {
        "Id": "42c6ba14eb8290523f1aed8555cac94ab4f49a66649b88525fb49e983b57d421",
        "Created": "2017-04-27T10:20:12.661951433Z",
        "Path": "sleep",
        "Args": [
            "300"
        ],
        ...
       "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "00459ecae751e8380e9c3324e7d48b57857eb32a7ed3e9d8214dc3a2301478fa",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/00459ecae751",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "a9e424191b4f299478e9f7e4efc09fda777922c751d56c9ddda04f427100eb56",
            "Gateway": "172.17.42.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.138",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:8a",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "d006861e46aa37297f0161085970253d75643f7c0e88c6bd457e85de0a5721e9",
                    "EndpointID": "a9e424191b4f299478e9f7e4efc09fda777922c751d56c9ddda04f427100eb56",
                    "Gateway": "172.17.42.1",
                    "IPAddress": "172.17.0.138",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:8a"
                }
            }
      ....

another container in the same node,

liutianwei@dis2 ~ $ docker inspect cranky_ardinghelli
[
    {
        "Id": "1032cc70f1261d35e71f95e9c0346d76aceb3d4d78346106047f1af5a4575e7b",
        "Created": "2017-04-27T10:20:12.661774678Z",
        "Path": "sleep",
        "Args": [
            "300"
        ],
       ...
           "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "94320ad7cc5620f3bf0a7b62ea8297e547d85109fb84e262c4ab3ee901927867",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/94320ad7cc56",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "1bf6669fa9a6f1457257ba9f26428712e16b2abb075fb64c759625a7973620bf",
            "Gateway": "172.17.42.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.138",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:8a",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "d006861e46aa37297f0161085970253d75643f7c0e88c6bd457e85de0a5721e9",
                    "EndpointID": "1bf6669fa9a6f1457257ba9f26428712e16b2abb075fb64c759625a7973620bf",
                    "Gateway": "172.17.42.1",
                    "IPAddress": "172.17.0.138",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:8a"
                }
            }
        }

they both use same ip(172.17.0.138) at the same time.


Describe the results you expected
different containers use different ip in bridge network mode at the same time.


Additional information you deem important (e.g. issue happens only occasionally)

Output of docker version

Client:
 Version:      17.04.0-ce
 API version:  1.28
 Go version:   go1.7.5
 Git commit:   4845c56
 Built:        Thu Apr 13 16:46:18 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.04.0-ce
 API version:  1.28 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   4845c56
 Built:        Thu Apr 13 16:46:18 2017
 OS/Arch:      linux/amd64
 Experimental: false

Output of docker info

Containers: 45
 Running: 43
 Paused: 0
 Stopped: 2
Images: 252
Server Version: 17.04.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary:
containerd version: 422e31ce907fd9c3833a38d7b8fdd023e5a76e73
runc version: 9c2d8d1 (expected: 9c2d8d184e5da67c95d601382adf14862e4f2228)
init version: N/A (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.4.6-gentoo
Operating System: Gentoo/Linux
OSType: linux
Architecture: x86_64
CPUs: 24
Total Memory: 94.38GiB
Name: jolly2
ID: Q6WD:UODY:625I:7JPL:FOUL:JLW3:2H3T:KSRD:G5SR:OFOL:T6NR:KHN6
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Output of Linux kernal

Linux jolly2 4.4.6-gentoo #2 SMP Tue Sep 20 16:30:08 CST 2016 x86_64 Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHz GenuineIntel GNU/Linux

cmd of docker daemon

dockerd \
        --log-level info \
        -H unix:///var/run/docker.sock \
        --bip=172.17.42.1/16 \
        --max-concurrent-downloads=10 \
        --max-concurrent-uploads=8 \
        --oom-score-adjust=-1000 \
        --storage-driver=overlay2 \
        --shutdown-timeout 120 \

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the provided Python multiprocessing script against Docker 17.04.0 with the shown --bip configuration, then use docker inspect to compare bridge IPs across the created containers. Investigate bridge-network IP allocation under concurrent container creation; done means concurrently running containers receive distinct IP addresses.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.