0

I'm using Hashicorp Nomad to orchestrate Docker containers, and I'm facing a networking challenge. My current setup uses host networking (network_mode = "host") in the Docker+Nomad job specification, which allows my containers to access services on our internal network, (for example like 10.0.0.9).

However, this prevents zero-downtime deployments due to port conflicts, (I'm running on a single host here).

I'm looking to:

  1. Allow the Docker containers to access internal network IPs (10.0.0.x range)
  2. Enable zero-downtime deployments

The internal network is managed via hetzner. I was looking into potentially using macvlan networking for the docker container however there isn't much information about this that I could find (relating to nomad). How could I achieve this functionality?

I tried doing:

docker network create \
  -d macvlan \
  --subnet=10.0.0.0/24 \
  --gateway=10.0.0.1 \
  -o parent=eth0 my_macvlan

In my nomad job setting:

        network_mode = "my_macvlan"

However it seems to assign an incorrect ip ("IPAddress": "10.0.0.2" - which is already assigned to an existing unrelated node on the private network).

I got this information from:

        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "addfebaebe8526ed4f8ed26a8807c495a540ef2dd155d4afe8ad5f53e6766612",
            "SandboxKey": "/var/run/docker/netns/addfebaebe85",
            "Ports": {},
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "my_macvlan": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "MacAddress": "02:42:0a:00:00:02",
                    "DriverOpts": null,
                    "NetworkID": "5545a9dcadc4a4faf2fdecefd04761406ff3fb6ae13c01947556c90fc283924c",
                    "EndpointID": "be8b68affc7e9437985a1122b4e68581172d8398e1a43231d69d155e0e25410f",
                    "Gateway": "10.0.0.1",
                    "IPAddress": "10.0.0.2",
                    "IPPrefixLen": 24,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "DNSNames": [
                        "ebay-notifications-65593115-5ae6-4bbd-e906-a4249439bea4",
                        "3d98450a6e86"
                    ]
                }
            }
        }
    }
McMaco
  • 131
Chris Stryczynski
  • 2,138
  • 3
  • 24
  • 30

0 Answers0