Mapping port to access webinterface












1














I have a barebones server, running Linux, but no graphical interface is installed. It's only working in command line and we don't want to change that.



The IP address of this server is 192.168.1.6



On this machine we run Docker to use multi containers. One of the container is a web app accessible by port 80.



When I curl localhost on my barebones Linux I have the raw data of the webpage. I would like to see the web app from every computer on the same LAN. By example on machine 192.168.1.7, I would like to type in a browser 192.168.1.6 and see the web app.



First of all, is it possible? If yes, can you provide me some guidelines?










share|improve this question
























  • This shows all the ways - blog.oddbit.com/2014/08/11/four-ways-to-connect-a-docker. If you just want to get started see here - forums.docker.com/t/….
    – slm
    Jul 27 at 7:45












  • Official docs as well - docs.docker.com/network/network-tutorial-host
    – slm
    Jul 27 at 7:55
















1














I have a barebones server, running Linux, but no graphical interface is installed. It's only working in command line and we don't want to change that.



The IP address of this server is 192.168.1.6



On this machine we run Docker to use multi containers. One of the container is a web app accessible by port 80.



When I curl localhost on my barebones Linux I have the raw data of the webpage. I would like to see the web app from every computer on the same LAN. By example on machine 192.168.1.7, I would like to type in a browser 192.168.1.6 and see the web app.



First of all, is it possible? If yes, can you provide me some guidelines?










share|improve this question
























  • This shows all the ways - blog.oddbit.com/2014/08/11/four-ways-to-connect-a-docker. If you just want to get started see here - forums.docker.com/t/….
    – slm
    Jul 27 at 7:45












  • Official docs as well - docs.docker.com/network/network-tutorial-host
    – slm
    Jul 27 at 7:55














1












1








1







I have a barebones server, running Linux, but no graphical interface is installed. It's only working in command line and we don't want to change that.



The IP address of this server is 192.168.1.6



On this machine we run Docker to use multi containers. One of the container is a web app accessible by port 80.



When I curl localhost on my barebones Linux I have the raw data of the webpage. I would like to see the web app from every computer on the same LAN. By example on machine 192.168.1.7, I would like to type in a browser 192.168.1.6 and see the web app.



First of all, is it possible? If yes, can you provide me some guidelines?










share|improve this question















I have a barebones server, running Linux, but no graphical interface is installed. It's only working in command line and we don't want to change that.



The IP address of this server is 192.168.1.6



On this machine we run Docker to use multi containers. One of the container is a web app accessible by port 80.



When I curl localhost on my barebones Linux I have the raw data of the webpage. I would like to see the web app from every computer on the same LAN. By example on machine 192.168.1.7, I would like to type in a browser 192.168.1.6 and see the web app.



First of all, is it possible? If yes, can you provide me some guidelines?







docker port-forwarding






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 16 at 21:39









Rui F Ribeiro

38.9k1479129




38.9k1479129










asked Jul 27 at 7:33









Raccoon

1404




1404












  • This shows all the ways - blog.oddbit.com/2014/08/11/four-ways-to-connect-a-docker. If you just want to get started see here - forums.docker.com/t/….
    – slm
    Jul 27 at 7:45












  • Official docs as well - docs.docker.com/network/network-tutorial-host
    – slm
    Jul 27 at 7:55


















  • This shows all the ways - blog.oddbit.com/2014/08/11/four-ways-to-connect-a-docker. If you just want to get started see here - forums.docker.com/t/….
    – slm
    Jul 27 at 7:45












  • Official docs as well - docs.docker.com/network/network-tutorial-host
    – slm
    Jul 27 at 7:55
















This shows all the ways - blog.oddbit.com/2014/08/11/four-ways-to-connect-a-docker. If you just want to get started see here - forums.docker.com/t/….
– slm
Jul 27 at 7:45






This shows all the ways - blog.oddbit.com/2014/08/11/four-ways-to-connect-a-docker. If you just want to get started see here - forums.docker.com/t/….
– slm
Jul 27 at 7:45














Official docs as well - docs.docker.com/network/network-tutorial-host
– slm
Jul 27 at 7:55




Official docs as well - docs.docker.com/network/network-tutorial-host
– slm
Jul 27 at 7:55










1 Answer
1






active

oldest

votes


















0














There are many ways to do this the most straightforward is to use Docker's built in networking.



$ docker network ls
NETWORK ID NAME DRIVER SCOPE
6ef2c6836690 bridge bridge local
db24b1e2be58 host host local
edf606d533a5 none null local


By default your container goes into the bridge network, unless you tell it otherwise during the docker run....



$ docker run -P -d -p 12345:80 nginxdemos/hello


Once you do this any host on the LAN can reach it using the IP of the Docker Host + the port:



$ curl -I http://192.168.56.101:12345/
HTTP/1.1 200 OK
Server: nginx/1.13.8
Date: Fri, 27 Jul 2018 08:26:02 GMT
Content-Type: text/html
Connection: keep-alive
Expires: Fri, 27 Jul 2018 08:26:01 GMT
Cache-Control: no-cache


Firewalls



Keep in mind that you're Docker Host's firewall may be the cause of traffic not ingressing/egressing to/from the Docker container. In some situations, you may need to add the Docker Host's port (12345 in my example above) to an allow list so that hosts outside of Docker Host can access this port.



References




  • Connecting Docker Containers, Part One

  • Docker networking overview

  • Docker - Use bridge networks

  • How To Set Up a Firewall Using FirewallD on CentOS 7

  • nginx container

  • nginxdemos/hello container






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    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: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2funix.stackexchange.com%2fquestions%2f458773%2fmapping-port-to-access-webinterface%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














    There are many ways to do this the most straightforward is to use Docker's built in networking.



    $ docker network ls
    NETWORK ID NAME DRIVER SCOPE
    6ef2c6836690 bridge bridge local
    db24b1e2be58 host host local
    edf606d533a5 none null local


    By default your container goes into the bridge network, unless you tell it otherwise during the docker run....



    $ docker run -P -d -p 12345:80 nginxdemos/hello


    Once you do this any host on the LAN can reach it using the IP of the Docker Host + the port:



    $ curl -I http://192.168.56.101:12345/
    HTTP/1.1 200 OK
    Server: nginx/1.13.8
    Date: Fri, 27 Jul 2018 08:26:02 GMT
    Content-Type: text/html
    Connection: keep-alive
    Expires: Fri, 27 Jul 2018 08:26:01 GMT
    Cache-Control: no-cache


    Firewalls



    Keep in mind that you're Docker Host's firewall may be the cause of traffic not ingressing/egressing to/from the Docker container. In some situations, you may need to add the Docker Host's port (12345 in my example above) to an allow list so that hosts outside of Docker Host can access this port.



    References




    • Connecting Docker Containers, Part One

    • Docker networking overview

    • Docker - Use bridge networks

    • How To Set Up a Firewall Using FirewallD on CentOS 7

    • nginx container

    • nginxdemos/hello container






    share|improve this answer


























      0














      There are many ways to do this the most straightforward is to use Docker's built in networking.



      $ docker network ls
      NETWORK ID NAME DRIVER SCOPE
      6ef2c6836690 bridge bridge local
      db24b1e2be58 host host local
      edf606d533a5 none null local


      By default your container goes into the bridge network, unless you tell it otherwise during the docker run....



      $ docker run -P -d -p 12345:80 nginxdemos/hello


      Once you do this any host on the LAN can reach it using the IP of the Docker Host + the port:



      $ curl -I http://192.168.56.101:12345/
      HTTP/1.1 200 OK
      Server: nginx/1.13.8
      Date: Fri, 27 Jul 2018 08:26:02 GMT
      Content-Type: text/html
      Connection: keep-alive
      Expires: Fri, 27 Jul 2018 08:26:01 GMT
      Cache-Control: no-cache


      Firewalls



      Keep in mind that you're Docker Host's firewall may be the cause of traffic not ingressing/egressing to/from the Docker container. In some situations, you may need to add the Docker Host's port (12345 in my example above) to an allow list so that hosts outside of Docker Host can access this port.



      References




      • Connecting Docker Containers, Part One

      • Docker networking overview

      • Docker - Use bridge networks

      • How To Set Up a Firewall Using FirewallD on CentOS 7

      • nginx container

      • nginxdemos/hello container






      share|improve this answer
























        0












        0








        0






        There are many ways to do this the most straightforward is to use Docker's built in networking.



        $ docker network ls
        NETWORK ID NAME DRIVER SCOPE
        6ef2c6836690 bridge bridge local
        db24b1e2be58 host host local
        edf606d533a5 none null local


        By default your container goes into the bridge network, unless you tell it otherwise during the docker run....



        $ docker run -P -d -p 12345:80 nginxdemos/hello


        Once you do this any host on the LAN can reach it using the IP of the Docker Host + the port:



        $ curl -I http://192.168.56.101:12345/
        HTTP/1.1 200 OK
        Server: nginx/1.13.8
        Date: Fri, 27 Jul 2018 08:26:02 GMT
        Content-Type: text/html
        Connection: keep-alive
        Expires: Fri, 27 Jul 2018 08:26:01 GMT
        Cache-Control: no-cache


        Firewalls



        Keep in mind that you're Docker Host's firewall may be the cause of traffic not ingressing/egressing to/from the Docker container. In some situations, you may need to add the Docker Host's port (12345 in my example above) to an allow list so that hosts outside of Docker Host can access this port.



        References




        • Connecting Docker Containers, Part One

        • Docker networking overview

        • Docker - Use bridge networks

        • How To Set Up a Firewall Using FirewallD on CentOS 7

        • nginx container

        • nginxdemos/hello container






        share|improve this answer












        There are many ways to do this the most straightforward is to use Docker's built in networking.



        $ docker network ls
        NETWORK ID NAME DRIVER SCOPE
        6ef2c6836690 bridge bridge local
        db24b1e2be58 host host local
        edf606d533a5 none null local


        By default your container goes into the bridge network, unless you tell it otherwise during the docker run....



        $ docker run -P -d -p 12345:80 nginxdemos/hello


        Once you do this any host on the LAN can reach it using the IP of the Docker Host + the port:



        $ curl -I http://192.168.56.101:12345/
        HTTP/1.1 200 OK
        Server: nginx/1.13.8
        Date: Fri, 27 Jul 2018 08:26:02 GMT
        Content-Type: text/html
        Connection: keep-alive
        Expires: Fri, 27 Jul 2018 08:26:01 GMT
        Cache-Control: no-cache


        Firewalls



        Keep in mind that you're Docker Host's firewall may be the cause of traffic not ingressing/egressing to/from the Docker container. In some situations, you may need to add the Docker Host's port (12345 in my example above) to an allow list so that hosts outside of Docker Host can access this port.



        References




        • Connecting Docker Containers, Part One

        • Docker networking overview

        • Docker - Use bridge networks

        • How To Set Up a Firewall Using FirewallD on CentOS 7

        • nginx container

        • nginxdemos/hello container







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 27 at 8:33









        slm

        247k66508675




        247k66508675






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • 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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2funix.stackexchange.com%2fquestions%2f458773%2fmapping-port-to-access-webinterface%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

            Morgemoulin

            Scott Moir

            Souastre