"Trying to map ports but no network interface is available"

843 views
Skip to first unread message

Stefan Smith

unread,
Nov 21, 2015, 8:08:56 PM11/21/15
to Nomad
Hi,

When I POST the below JSON to /v1/jobs, the container fails to start and /var/log/messages contains the following lines:

Nov 22 01:01:17 localhost nomad: 2015/11/22 01:01:17 [DEBUG] driver.docker: networking mode not specified; defaulting to bridge
Nov 22 01:01:17 localhost nomad: 2015/11/22 01:01:17 [DEBUG] driver.docker: No network interfaces are available
Nov 22 01:01:17 localhost nomad: 2015/11/22 01:01:17 [ERR] driver.docker: failed to create container configuration for image registry:2: Trying to map ports but no network interface is available
Nov 22 01:01:17 localhost nomad: 2015/11/22 01:01:17 [ERR] client: failed to start task 'docker-registry-2' for alloc 'b9b26630-7a08-d246-ec90-bd576e892f09': Failed to create container configuration for image registry:2: Trying to map ports but no network interface is available

If I omit the "port_map" property from the task config, the container starts fine. Any idea what's going on?

Cheers,

Stef

{
    "Job": {
        "ID" : "docker-registry-2",
        "Region" : "global",
        "Type" : "service",
        "Priority" : 1,
        "Datacenters": [
            "dc1"
        ],
        "Name": "docker-registry-2",
        "TaskGroups": [
            {
                "Count" : 1,
                "Name": "docker-registry-2",
                "RestartPolicy" : {
                    "Attempts" : 10
                },
                "Tasks": [
                    {
                        "Name": "docker-registry-2",
                        "Driver": "docker",
                        "Port" : {
                                "http" : {
                                        "static" : 5000
                                }
                        },
                        "Service": {
                            "Port": "http"
                        },
                        "Config": {
                            "image": "registry:2",
                            "port_map" : [{ "http" : 5000  }]
                        },
                        "Resources": {
                            "CPU" : 500,
                            "MemoryMB" : 128,
                            "DiskMB" : 0,
                            "Network": {
                                "MBits" : 100,
                                "Reserved_Ports": [
                                    "5000"
                                ]
                            }
                        }
                    }
                ]
            }
        ]
    }
}

Diptanu Choudhury

unread,
Nov 26, 2015, 11:37:03 PM11/26/15
to Stefan Smith, Nomad
Hi Stefan,

The json you're posting is incorrect. The port mapping section goes into the driver config now. I have already responded to your other email with the correct json, but in case this comes up in a web search for someone else trying to debug the same issue, here is the correct json -

  "Tasks": [
                    {
                        "Name": "docker-registry-2",
                        "Driver": "docker",
                        "Port" : {
                                "http" : {
                                        "static" : 5000
                                }
                        },
                        "Services": [
                            {
                                "Name": "${BASE}-foo",
                                "PortLabel": "http"
                            }
                        ],
                        "Config": {
                            "image": "registry:2"
                        },
                        "Resources": {
                            "CPU" : 500,
                            "MemoryMB" : 128,
                            "DiskMB" : 0,
                            "Networks": [
                                {
                                    "ReservedPorts": [
                                    {
                                        "Label": "http",
                                        "Value": 5000
                                    }
                                    ]
                                }
                            ]
                        }
                    }
                ]

Hope this helps, and please let us know if you face any other issue with port forwarding!

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/nomad/issues
IRC: #nomad-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Nomad" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nomad-tool+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nomad-tool/5ff3a9ba-72e2-4bcc-bb8e-3258f88b16c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks,
Diptanu Choudhury

Stefan Smith

unread,
Nov 30, 2015, 9:01:39 AM11/30/15
to Nomad
As mentioned in the other thread, this worked for me. Thanks.

Stef

Calvin Leung Huang

unread,
Jan 5, 2016, 5:38:50 PM1/5/16
to Nomad
Stefan, 

Thanks for posting the config up, it helped me get unblocked from issues I was having with the API. One quick question though, why did you use ReservedPort instead of DynamicPort? Is it because you wanted the 1:1 mapping? Doesn't that restrict the service to only be able to run one copy on that host?


- Calvin
Reply all
Reply to author
Forward
0 new messages