Docker Compose with static public IP over LAN but different with Host IP












0















I have the requirement where I need to expose all my containers through a static public IP.
However, the static public IP cannot be host IP because host IP must be dynamic.



The 2 solutions I found is macvlan and linux secondary IP, but base on my understanding, they cannot fulfil my need.



with macvlan, each container will get individual IP. I need to access all container through the same IP.



with linux secondary IP, I can assign a single static IP which exclusive for my docker container. However, I didn't found a way to manage the /etc/network/interface inside a docker container.



My question is:




  1. Is it possible to set all container using same ip using macvlan?

  2. Is there any way to manage/etc/network/interface, include ifup and ifdown inside a docker container?

  3. Is there any alternative method


Edit:
the image is the system design for what I wish to achieve:



System design










share|improve this question





























    0















    I have the requirement where I need to expose all my containers through a static public IP.
    However, the static public IP cannot be host IP because host IP must be dynamic.



    The 2 solutions I found is macvlan and linux secondary IP, but base on my understanding, they cannot fulfil my need.



    with macvlan, each container will get individual IP. I need to access all container through the same IP.



    with linux secondary IP, I can assign a single static IP which exclusive for my docker container. However, I didn't found a way to manage the /etc/network/interface inside a docker container.



    My question is:




    1. Is it possible to set all container using same ip using macvlan?

    2. Is there any way to manage/etc/network/interface, include ifup and ifdown inside a docker container?

    3. Is there any alternative method


    Edit:
    the image is the system design for what I wish to achieve:



    System design










    share|improve this question



























      0












      0








      0








      I have the requirement where I need to expose all my containers through a static public IP.
      However, the static public IP cannot be host IP because host IP must be dynamic.



      The 2 solutions I found is macvlan and linux secondary IP, but base on my understanding, they cannot fulfil my need.



      with macvlan, each container will get individual IP. I need to access all container through the same IP.



      with linux secondary IP, I can assign a single static IP which exclusive for my docker container. However, I didn't found a way to manage the /etc/network/interface inside a docker container.



      My question is:




      1. Is it possible to set all container using same ip using macvlan?

      2. Is there any way to manage/etc/network/interface, include ifup and ifdown inside a docker container?

      3. Is there any alternative method


      Edit:
      the image is the system design for what I wish to achieve:



      System design










      share|improve this question
















      I have the requirement where I need to expose all my containers through a static public IP.
      However, the static public IP cannot be host IP because host IP must be dynamic.



      The 2 solutions I found is macvlan and linux secondary IP, but base on my understanding, they cannot fulfil my need.



      with macvlan, each container will get individual IP. I need to access all container through the same IP.



      with linux secondary IP, I can assign a single static IP which exclusive for my docker container. However, I didn't found a way to manage the /etc/network/interface inside a docker container.



      My question is:




      1. Is it possible to set all container using same ip using macvlan?

      2. Is there any way to manage/etc/network/interface, include ifup and ifdown inside a docker container?

      3. Is there any alternative method


      Edit:
      the image is the system design for what I wish to achieve:



      System design







      docker docker-compose






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 2 at 7:29







      King Wei Lo

















      asked Jan 1 at 14:11









      King Wei LoKing Wei Lo

      167




      167
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Assign the static IP to your host and use the ordinary docker run -p option. The host is allowed to have multiple IP addresses (it presumably already has its dynamic IP address and the Docker-internal 172.17.0.1 address) and you can use an additional parameter to docker run -p 10.10.10.10:80:8888 to bind to a specific host address (that specific address and no other, port 80, forwards to port 8888 in the container).



          Another good setup is to provision a load balancer of some sort, assign the static IP address to it, and have it forward to the host. This is also helpful if you want to put some level of rate-limiting or basic HTTP filtering at this layer.



          There's no specific technical barrier to running ifconfig by hand inside a container, but no off-the-shelf images expects to need to do it, which means you'll need to write all of your own images that won't really be reusable outside this specific environment. A developer might have trouble running the identical image locally, for instance.






          share|improve this answer
























          • Just to clarify, basically your answer is similar to my second approach, and additionally bind the container to specific IP?

            – King Wei Lo
            Jan 1 at 23:55











          • The containers don't know they're being NATted to a specific static IP address.

            – David Maze
            Jan 2 at 0:31











          • Understand, I've uploaded an image and I guess it same with the solution provided by you.

            – King Wei Lo
            Jan 2 at 8:09











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53996149%2fdocker-compose-with-static-public-ip-over-lan-but-different-with-host-ip%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Assign the static IP to your host and use the ordinary docker run -p option. The host is allowed to have multiple IP addresses (it presumably already has its dynamic IP address and the Docker-internal 172.17.0.1 address) and you can use an additional parameter to docker run -p 10.10.10.10:80:8888 to bind to a specific host address (that specific address and no other, port 80, forwards to port 8888 in the container).



          Another good setup is to provision a load balancer of some sort, assign the static IP address to it, and have it forward to the host. This is also helpful if you want to put some level of rate-limiting or basic HTTP filtering at this layer.



          There's no specific technical barrier to running ifconfig by hand inside a container, but no off-the-shelf images expects to need to do it, which means you'll need to write all of your own images that won't really be reusable outside this specific environment. A developer might have trouble running the identical image locally, for instance.






          share|improve this answer
























          • Just to clarify, basically your answer is similar to my second approach, and additionally bind the container to specific IP?

            – King Wei Lo
            Jan 1 at 23:55











          • The containers don't know they're being NATted to a specific static IP address.

            – David Maze
            Jan 2 at 0:31











          • Understand, I've uploaded an image and I guess it same with the solution provided by you.

            – King Wei Lo
            Jan 2 at 8:09
















          0














          Assign the static IP to your host and use the ordinary docker run -p option. The host is allowed to have multiple IP addresses (it presumably already has its dynamic IP address and the Docker-internal 172.17.0.1 address) and you can use an additional parameter to docker run -p 10.10.10.10:80:8888 to bind to a specific host address (that specific address and no other, port 80, forwards to port 8888 in the container).



          Another good setup is to provision a load balancer of some sort, assign the static IP address to it, and have it forward to the host. This is also helpful if you want to put some level of rate-limiting or basic HTTP filtering at this layer.



          There's no specific technical barrier to running ifconfig by hand inside a container, but no off-the-shelf images expects to need to do it, which means you'll need to write all of your own images that won't really be reusable outside this specific environment. A developer might have trouble running the identical image locally, for instance.






          share|improve this answer
























          • Just to clarify, basically your answer is similar to my second approach, and additionally bind the container to specific IP?

            – King Wei Lo
            Jan 1 at 23:55











          • The containers don't know they're being NATted to a specific static IP address.

            – David Maze
            Jan 2 at 0:31











          • Understand, I've uploaded an image and I guess it same with the solution provided by you.

            – King Wei Lo
            Jan 2 at 8:09














          0












          0








          0







          Assign the static IP to your host and use the ordinary docker run -p option. The host is allowed to have multiple IP addresses (it presumably already has its dynamic IP address and the Docker-internal 172.17.0.1 address) and you can use an additional parameter to docker run -p 10.10.10.10:80:8888 to bind to a specific host address (that specific address and no other, port 80, forwards to port 8888 in the container).



          Another good setup is to provision a load balancer of some sort, assign the static IP address to it, and have it forward to the host. This is also helpful if you want to put some level of rate-limiting or basic HTTP filtering at this layer.



          There's no specific technical barrier to running ifconfig by hand inside a container, but no off-the-shelf images expects to need to do it, which means you'll need to write all of your own images that won't really be reusable outside this specific environment. A developer might have trouble running the identical image locally, for instance.






          share|improve this answer













          Assign the static IP to your host and use the ordinary docker run -p option. The host is allowed to have multiple IP addresses (it presumably already has its dynamic IP address and the Docker-internal 172.17.0.1 address) and you can use an additional parameter to docker run -p 10.10.10.10:80:8888 to bind to a specific host address (that specific address and no other, port 80, forwards to port 8888 in the container).



          Another good setup is to provision a load balancer of some sort, assign the static IP address to it, and have it forward to the host. This is also helpful if you want to put some level of rate-limiting or basic HTTP filtering at this layer.



          There's no specific technical barrier to running ifconfig by hand inside a container, but no off-the-shelf images expects to need to do it, which means you'll need to write all of your own images that won't really be reusable outside this specific environment. A developer might have trouble running the identical image locally, for instance.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 1 at 20:08









          David MazeDavid Maze

          15k31429




          15k31429













          • Just to clarify, basically your answer is similar to my second approach, and additionally bind the container to specific IP?

            – King Wei Lo
            Jan 1 at 23:55











          • The containers don't know they're being NATted to a specific static IP address.

            – David Maze
            Jan 2 at 0:31











          • Understand, I've uploaded an image and I guess it same with the solution provided by you.

            – King Wei Lo
            Jan 2 at 8:09



















          • Just to clarify, basically your answer is similar to my second approach, and additionally bind the container to specific IP?

            – King Wei Lo
            Jan 1 at 23:55











          • The containers don't know they're being NATted to a specific static IP address.

            – David Maze
            Jan 2 at 0:31











          • Understand, I've uploaded an image and I guess it same with the solution provided by you.

            – King Wei Lo
            Jan 2 at 8:09

















          Just to clarify, basically your answer is similar to my second approach, and additionally bind the container to specific IP?

          – King Wei Lo
          Jan 1 at 23:55





          Just to clarify, basically your answer is similar to my second approach, and additionally bind the container to specific IP?

          – King Wei Lo
          Jan 1 at 23:55













          The containers don't know they're being NATted to a specific static IP address.

          – David Maze
          Jan 2 at 0:31





          The containers don't know they're being NATted to a specific static IP address.

          – David Maze
          Jan 2 at 0:31













          Understand, I've uploaded an image and I guess it same with the solution provided by you.

          – King Wei Lo
          Jan 2 at 8:09





          Understand, I've uploaded an image and I guess it same with the solution provided by you.

          – King Wei Lo
          Jan 2 at 8:09




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53996149%2fdocker-compose-with-static-public-ip-over-lan-but-different-with-host-ip%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith