Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static IP for container with driver overlay #31345

Closed
prapdm opened this issue Feb 24, 2017 · 3 comments
Closed

Static IP for container with driver overlay #31345

prapdm opened this issue Feb 24, 2017 · 3 comments
Labels
area/networking area/stack kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. version/1.13

Comments

@prapdm
Copy link

prapdm commented Feb 24, 2017

Description

Steps to reproduce the issue:

  1. docker network create --driver overlay --subnet 10.40.1.0/24 --gateway 10.40.1.1 mynetwork
  2. Create test.yml file:
version: '3'
services:
  test:
    image: nginx:stable-alpine
    networks:
     my_network:
       ipv4_address: 10.40.1.20
   
networks:
 my_network:
   external:
     name: mynetwork
  1. docker stack deploy --compose-file=test.yml ng
  2. docker exec -it 0dbca750f536 hostname -i

Describe the results you received:

docker exec -it 0dbca750f536 hostname -i
10.40.0.3

Describe the results you expected:

docker exec -it 0dbca750f536 hostname -i
10.40.1.20

Output of docker version:

docker version
Client:
 Version:      1.13.0
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Tue Jan 17 09:55:28 2017
 OS/Arch:      linux/amd64

Server:
 Version:      1.13.0
 API version:  1.25 (minimum version 1.12)
 Go version:   go1.7.3
 Git commit:   49bf474
 Built:        Tue Jan 17 09:55:28 2017
 OS/Arch:      linux/amd64
 Experimental: false

Output of docker info:

Containers: 2
 Running: 1
 Paused: 0
 Stopped: 1
Images: 40
Server Version: 1.13.0
Storage Driver: overlay
 Backing Filesystem: xfs
 Supports d_type: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local local-persist
 Network: bridge host macvlan null overlay
Swarm: active
 NodeID: *******************
 Is Manager: true
 ClusterID: *******************
 Managers: 3
 Nodes: 5
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
 Node Address: ********
 Manager Addresses:
******:2377
******:2377
******:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 03e5862ec0d8d3b3f750e19fca3ee367e13c090e
runc version: 2f7393a47307a16f8cee44a37b262e8b81021e3e
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-514.6.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.907 GiB
Name: ***.***.pl
ID: ******************
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: *****
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
@trennepohl
Copy link

I'm facing the same issue, any workaround?

network inspect:

[
    {
        "Name": "demo_demo-network",
        "Id": "qkz753dgyi3whzg8v2585xgnw",
        "Created": "2017-03-15T16:34:04.4570162-03:00",
        "Scope": "swarm",
        "Driver": "overlay",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.21.0.0/16",
                    "Gateway": "172.21.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {
            "0b4393bfa6f3393b1b9660defd38b42bb1944cf77d53c828c5fb059d40c5180d": {
                "Name": "demo_agilepromoter-web-demo.1.27b74lz56o9u6cvhm65n2nl87",
                "EndpointID": "07fa53340f8934ae3f022388aefbca2afc61fa5bff66d36f5105b2815ec2b90d",
                "MacAddress": "02:42:ac:15:00:06",
                "IPv4Address": "172.21.0.6/16",
                "IPv6Address": ""
            },
            "1b7c48137f32c170c37462a1efba74219b908584ceeb407febb0d036a6311b44": {
                "Name": "demo_involves-proxy.1.icsct0u57dusjsh54h93bf7h2",
                "EndpointID": "ef722bc9fcda547065102ffbb8b4cf0838e786db226f5170aed7df7eba471b40",
                "MacAddress": "02:42:ac:15:00:05",
                "IPv4Address": "172.21.0.5/16",
                "IPv6Address": ""
            },
            "3459a415cb3b2c269dda9931cd1f244a476b276a89b46c170c90b8e454713d0c": {
                "Name": "consul_consul.1.okexirwxvnjgg99jtx7mf6t07",
                "EndpointID": "a6347480755a7051e72a360ce392eb9173078c1002cde387f3770a35699fef09",
                "MacAddress": "02:42:ac:15:00:07",
                "IPv4Address": "172.21.0.7/16",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.driver.overlay.vxlanid_list": "4097"
        },
        "Labels": {
            "com.docker.stack.namespace": "demo"
        },
        "Peers": [
            {
                "Name": "ubuntu-xenial-ab5cbf3f4bc9",
                "IP": "_xXXXXXxxxxxx_"
            }
        ]
    }
]

compose file:

services:
  consul:
    image: consul
    networks:
      demo:
        ipv4_address: 172.21.0.21
    command: agent -server  -bind=172.21.0.21 -client=0.0.0.0  -bootstrap -ui


networks:
  demo:
    external:
      name: demo_demo-network

docker inspect:

            "Bridge": "",
            "SandboxID": "d026cc5489e61ac81ec367eb19d97cd7a84077614856d32fcf19fd9713f26e39",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": null,
            "SandboxKey": "/var/run/docker/netns/d026cc5489e6",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "demo_demo-network": {
                    "IPAMConfig": {
                        "IPv4Address": "172.21.0.7"
                    },
                    "Links": null,
                    "Aliases": [
                        "352b6e8d1dcf"
                    ],
                    "NetworkID": "qkz753dgyi3whzg8v2585xgnw",
                    "EndpointID": "",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": ""
                }

docker info:

 Running: 2
 Paused: 0
 Stopped: 9
Images: 11
Server Version: 17.03.0-ce
Storage Driver: aufs
 Root Dir: /data/docker/aufs
 Backing Filesystem: extfs
 Dirs: 90
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: active
 NodeID: 0t5kyn2llpr6wg9gl9ervntsa
 Is Manager: true
 ClusterID: inj7j79lv9qyth7v7opbmwjnc
 Managers: 1
 Nodes: 1
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
 Node Address: 192.168.200.4
 Manager Addresses:
  192.168.200.4:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 977c511eda0925a723debdc94d09459af49d082a
runc version: a01dafd48bc1c7cc12bdb01206f9fea7dd6feb70
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-66-generic
Operating System: Ubuntu 16.04.2 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 2.414 GiB
Name: ubuntu-xenial
ID: TJMX:TKKB:Y3CY:NWP2:75KW:UB6U:XKD7:X5LJ:AY4N:BVHK:MFW4:6ENX
Docker Root Dir: /data/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

@thaJeztah
Copy link
Member

Thanks for reporting; Static IP addresses for services are not yet supported, see #25303 (and #24170, #29816).

I'll close this issue, because we're tracking this feature through those issues, and don't want the discussion to diverge. Implementing this for docker stack deploy depends on the feature being supported for services first. You can subscribe to those issues using the "subscribe" button.

Closing this issue, but feel free to comment after I closed 👍

@thaJeztah thaJeztah added area/stack kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. labels Mar 16, 2017
@rohithpeddi
Copy link

rohithpeddi commented Oct 25, 2017

I searched around and tried different possibilities and I was able to assign static ips to containers. I am pretty new to docker, I don't know if this is the right way though.

I created a swarm. In manager, I created an attachable overlay network with a subnet.

docker network create -d overlay --subnet=10.0.9.0/22 --attachable overlay-network

My docker compose:

version: "3.2"

services:
  hadoop-master:
    image: devhadoop-master
    container_name: hadoop-master
    .
    .
    .
    networks:
      overlay-network:
        ipv4_address: 10.0.9.22

networks:
  overlay-network:
    external: true

Note the configuration under default networks where external is true. That is what made it work.
Though I created the overlay-network with attachable flag, service in my worker was not able to connect to it. So I ran a docker run --rm --net overlay-network alpine sleep 1d to make overlay-network discoverable, then my worker-service able to connect to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/networking area/stack kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. version/1.13
Projects
None yet
Development

No branches or pull requests

5 participants