vmware / vic

vSphere Integrated Containers Engine is a container runtime for vSphere.
http://vmware.github.io/vic
Other
640 stars 173 forks source link

docker network create --ipam not full supported #3737

Open chengwang86 opened 7 years ago

chengwang86 commented 7 years ago

VIC version: 0.8

Deployment details:

bin/vic-machine-linux create --name=vch-3 --target=root:pwd@192.168.60.162 --thumbprint=... --volume-store=datastore1/test:default --no-tlsverify --no-tls

Steps to reproduce: docker -H 192.168.60.130:2375 network create --ipam-opt="driver=bridge" net1

Actual behavior:

docker -H 192.168.60.130:2375 network inspect net3
[
    {
        "Name": "net3",
        "Id": "1de562e785e7982811b926e2144a7d6b8040d4308bc9d432fc0f54d9e188dd5e",
        "Scope": "",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.18.0.0/16",
                    "Gateway": "172.18.0.1"
                }
            ]
        },
        "Internal": false,
        "Containers": {},
        "Options": {},
        "Labels": {}
    }
]

Expected behavior: "Driver": "bridge",

This is needed by the syntax "ipam" in the docker-compose file. See https://github.com/vmware/vic/issues/3635#issuecomment-275496609.

sflxn commented 7 years ago

This is in the inspect code. Once we correct that, we need to verify that compose works with this.

hmahmood commented 7 years ago

I do not believe this is relevant to our implementation, so we should only support it if docker compose is simply not going to work without it, and only then what is absolutely required for the docker compose to work.

andrewtchin commented 7 years ago

Docker:

docker network create --ipam-opt="driver=bridge" net5

[
    {
        "Name": "net5",
        "Id": "618d6edc9fea246fe3ef6152ecde5dbe41af19849f007cdb18e08debd3595050",
        "Created": "2017-03-09T07:49:03.267494786-08:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {
                "Driver": "bridge"
            },
            "Config": [
                {
                    "Subnet": "172.21.0.0/16",
                    "Gateway": "172.21.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {},
        "Options": {},
        "Labels": {}
    }
]

VIC:

docker -H 10.0.0.177:2375 network create --ipam-opt="driver=bridge" net6

[
    {
        "Name": "net6",
        "Id": "59bce8d01daba9510545040fbc9fda3cc3ff6ff84aac1c700bbf11d19acebb3e",
        "Created": "2017-03-09T15:51:31.421219473Z",
        "Scope": "",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {},
        "Options": {},
        "Labels": {}
    }
]

docker-compose -H 10.0.0.177:2375 up
Creating network "chin_app_net" with driver "bridge"
ERROR: at most one ipam config supported
andrewtchin commented 7 years ago

With defaults, VIC is not filling in Scope or IPAM.Driver

chin@ubuntu:~|⇒  docker network create net6
60984d22411bf70a09ca874270f43de16e4b5109d4b4f795aed5207cdbb2971c
chin@ubuntu:~|⇒  docker network inspect net6
[
    {
        "Name": "net6",
        "Id": "60984d22411bf70a09ca874270f43de16e4b5109d4b4f795aed5207cdbb2971c",
        "Created": "2017-03-13T09:37:15.065714569-07:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.22.0.0/16",
                    "Gateway": "172.22.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {},
        "Options": {},
        "Labels": {}
    }
]
chin@ubuntu:~|⇒  docker -H 10.17.109.134:2375 network create net6
0b9817894c94ee6179774f1a7d10b238062fe9484b40da52f90dd1518b131f75
chin@ubuntu:~|⇒  docker -H 10.17.109.134:2375 network inspect net6
[
    {
        "Name": "net6",
        "Id": "0b9817894c94ee6179774f1a7d10b238062fe9484b40da52f90dd1518b131f75",
        "Created": "2017-03-13T16:37:59.213910752Z",
        "Scope": "",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.18.0.0/16",
                    "Gateway": "172.18.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {},
        "Options": {},
        "Labels": {}
    }
]
andrewtchin commented 7 years ago
chin@ubuntu:~|⇒  cat docker-compose.yml 
version: '2.1'

services:
  app:
    image: busybox
    command: /bin/top
    networks:
      app_net:
        ipv4_address: 172.20.238.10

networks:
  app_net:
    driver: bridge
    enable_ipv6: true
    ipam:
      driver: default
      config:
      - subnet: 172.20.238.0/24
        gateway: 172.20.238.1

chin@ubuntu:~|⇒  docker-compose -H 10.17.109.134:2375 up -d
Creating network "chin_app_net" with driver "bridge"
Pulling app (busybox:latest)...
Pulling from library/busybox
7520415ce762: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:8d7fe3e157e56648ab790794970fbdfe82c84af79e807443b98df92c822a9b9b
Status: Downloaded newer image for library/busybox:latest
Creating chin_app_1

⇒  docker -H 10.17.109.134:2375 ps -a                                                                                                                                            
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
229f8439dec1        busybox             "/bin/top"          26 seconds ago      Up 25 seconds                           chin_app_1

chin@ubuntu:~/go/src/github.com/vmware/vic|3737/network-create-ipam⚡ 
⇒  docker -H 10.17.109.134:2375 network ls        
NETWORK ID          NAME                DRIVER              SCOPE
fb5cc4b3a40a        bridge              bridge              
62097b944ee8        chin_app_net        bridge              

chin@ubuntu:~/go/src/github.com/vmware/vic|3737/network-create-ipam⚡ 
⇒  docker -H 10.17.109.134:2375 network inspect chin_app_net
[
    {
        "Name": "chin_app_net",
        "Id": "62097b944ee81d52d77a328a8322e07dafaa9478ecd43946b0e6615b82248f2b",
        "Created": "2017-03-13T17:48:21.838279191Z",
        "Scope": "",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.20.238.0/24",
                    "Gateway": "172.20.238.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {
            "229f8439dec1116e14db8c2fb2fd3f54f3352c40b12e69101ead2c84b1e4f555": {
                "Name": "chin_app_1",
                "EndpointID": "229f8439dec1116e14db8c2fb2fd3f54f3352c40b12e69101ead2c84b1e4f555",
                "MacAddress": "",
                "IPv4Address": "172.20.238.10/24",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "app_net",
            "com.docker.compose.project": "chin"
        }
    }
]
andrewtchin commented 7 years ago

I verified docker-compose works, this is just a minor network inspect issue now - we are missing Scope and IPAM.Driver