• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Question Docker bind dedicated IP addresses to containers

kwendel

New Pleskian
Hi there!
I am running Plesk on a Ubuntu Server with multiple external IP addresses and want to bind an unused, dedicated ip address to a docker container.

So for example:
  • Main IP (shared) is 123.123.123.100
  • Docker Container 1 should be binded to 123.123.123.101 exclusively
  • Docker Container 2 should be binded to 123.123.123.102 exclusively
So i can use the same internal/external port for conainters.

And the setting sould be permanent, so that i can restart the containers over the Plesk Panel without loosing these bindings :)

I looked through the internet and forums but only could find a "docker run" command that binds to a specific ip address.
but this will not work if i am restarting the container over the docker menu in plesk panel.

Thanks for any help!
 
Hi,

I have the same question but only found this old post without any answer. Is it possible to route IPs to running docker containers?

Thanks!
Bruno
 
This depends how your container is connected to the network (which driver is used).

Basically if your container connects to user defined networks and has an IPAMConfig key you can set a static IP here, for example:

docker inspect <container>

JSON:
"NetworkSettings": {
        "Bridge": "",
        "EndpointID": "",
        "Gateway": "",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "HairpinMode": false,
        "IPAddress": "",
        "IPPrefixLen": 0,
        "IPv6Gateway": "",
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "MacAddress": "",
        "Networks": {
            "local": {
                "Aliases": [
                    "cc50756b4286"
                ],
                "DriverOpts": null,
                "EndpointID": "9a7b5c63d05...",
                "Gateway": "172.21.0.1",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "IPAMConfig": {
                    "IPv4Address": "172.21.0.3"
                },
                "IPAddress": "172.21.0.3",
                "IPPrefixLen": 16,
                "IPv6Gateway": "",
                "Links": null,
                "MacAddress": "02:42:ac:15:00:03",
                "NetworkID": "11d4d75df6ef39..."
            }
        },
        "SandboxID": "46fee1097b31...",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null
    },

If IPAMConfig ist not set, the default Network.IPAddress-key seems to work only for the standard bridge network but not for user created networks (but it may depend on the system):

JSON:
        "Networks": {
            "bridge": {
                "Aliases": null,
                "DriverOpts": null,
                "EndpointID": "1e7b279500....",
                "Gateway": "172.17.0.1",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "IPAMConfig": null,
                "IPAddress": "172.17.0.3",
                "IPPrefixLen": 16,
                "IPv6Gateway": "",
                "Links": null,
                "MacAddress": "02:42:ac:11:00:03",
                "NetworkID": "3a1822b3069...."
            }
        },

AFAIK docker still lacks an update command for that so you need to edit the configuration file (usually in):
/var/lib/docker/<container id>/config.v2.json

If you don't know how to set up your configuration properly just run a new container with the --ip argument set and inspect the configuration that was created.
 
Back
Top