Setup a Docker container to work with a local database












3















I'm trying to setup a Docker container to work with a local database.



The image is this one https://hub.docker.com/r/tuxgasy/dolibarr/ and it suggests to also create a mariadb container, and link it to that.



I would like to configure the Dolibarr container to instead use the mariadb database that I already have on my main system, that was installed from my distro's main repo.



It's the first time that I try to setup a working Docker application, and I'm not that expert about database maintenance, so I'm a bit lost.



How can I do this? Please keep the instructions ad clear and detailed as possible.



My system is a fully updated openSUSE Tumbleweed.










share|improve this question



























    3















    I'm trying to setup a Docker container to work with a local database.



    The image is this one https://hub.docker.com/r/tuxgasy/dolibarr/ and it suggests to also create a mariadb container, and link it to that.



    I would like to configure the Dolibarr container to instead use the mariadb database that I already have on my main system, that was installed from my distro's main repo.



    It's the first time that I try to setup a working Docker application, and I'm not that expert about database maintenance, so I'm a bit lost.



    How can I do this? Please keep the instructions ad clear and detailed as possible.



    My system is a fully updated openSUSE Tumbleweed.










    share|improve this question

























      3












      3








      3


      1






      I'm trying to setup a Docker container to work with a local database.



      The image is this one https://hub.docker.com/r/tuxgasy/dolibarr/ and it suggests to also create a mariadb container, and link it to that.



      I would like to configure the Dolibarr container to instead use the mariadb database that I already have on my main system, that was installed from my distro's main repo.



      It's the first time that I try to setup a working Docker application, and I'm not that expert about database maintenance, so I'm a bit lost.



      How can I do this? Please keep the instructions ad clear and detailed as possible.



      My system is a fully updated openSUSE Tumbleweed.










      share|improve this question














      I'm trying to setup a Docker container to work with a local database.



      The image is this one https://hub.docker.com/r/tuxgasy/dolibarr/ and it suggests to also create a mariadb container, and link it to that.



      I would like to configure the Dolibarr container to instead use the mariadb database that I already have on my main system, that was installed from my distro's main repo.



      It's the first time that I try to setup a working Docker application, and I'm not that expert about database maintenance, so I'm a bit lost.



      How can I do this? Please keep the instructions ad clear and detailed as possible.



      My system is a fully updated openSUSE Tumbleweed.







      linux database docker opensuse mariadb






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 28 '17 at 15:04









      SekhemtySekhemty

      3,909104480




      3,909104480






















          2 Answers
          2






          active

          oldest

          votes


















          4














          There are three ways:





          1. Use the --net=host option. This network mode essentially means that the container has direct access to localhost and you can now access localhost:3306. Here's the command



            docker run --net=host ... tuxgasy/dolibarr



            Then connect to mariadb with localhost:3306




          2. Mount the mariadb socket to the docker container and connect to mariadb via socket. For example if you configure the socket's location to be /var/run/mysqld/mysqld.sock then you could mount and use that as your connection point.



            docker run -v /var/run/mysqld:/mariadb_socket ... tuxgasy/dolibarr



            Then connect to mariadb via the socket /mariadb_socket/mysqld.sock from your app



          3. Use the docker host's ip. First get the host ip address on the docker network (in linux type
            ip addr show and look for the docker0 ip). This is usually something like 172.17.0.1 (your mileage may vary).
            Then you should be able to use that ip address to connect to mariadb for example 172.17.0.1:3306



          NOTE: ... means any other options that you may already be using






          share|improve this answer

































            0














            I've created a docker container for doing exactly that https://github.com/qoomon/docker-host



            You can then simply use container name dns to access host system from inside a container e.g. curl http://dockerhost:9200






            share|improve this answer























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "3"
              };
              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%2fsuperuser.com%2fquestions%2f1254515%2fsetup-a-docker-container-to-work-with-a-local-database%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              4














              There are three ways:





              1. Use the --net=host option. This network mode essentially means that the container has direct access to localhost and you can now access localhost:3306. Here's the command



                docker run --net=host ... tuxgasy/dolibarr



                Then connect to mariadb with localhost:3306




              2. Mount the mariadb socket to the docker container and connect to mariadb via socket. For example if you configure the socket's location to be /var/run/mysqld/mysqld.sock then you could mount and use that as your connection point.



                docker run -v /var/run/mysqld:/mariadb_socket ... tuxgasy/dolibarr



                Then connect to mariadb via the socket /mariadb_socket/mysqld.sock from your app



              3. Use the docker host's ip. First get the host ip address on the docker network (in linux type
                ip addr show and look for the docker0 ip). This is usually something like 172.17.0.1 (your mileage may vary).
                Then you should be able to use that ip address to connect to mariadb for example 172.17.0.1:3306



              NOTE: ... means any other options that you may already be using






              share|improve this answer






























                4














                There are three ways:





                1. Use the --net=host option. This network mode essentially means that the container has direct access to localhost and you can now access localhost:3306. Here's the command



                  docker run --net=host ... tuxgasy/dolibarr



                  Then connect to mariadb with localhost:3306




                2. Mount the mariadb socket to the docker container and connect to mariadb via socket. For example if you configure the socket's location to be /var/run/mysqld/mysqld.sock then you could mount and use that as your connection point.



                  docker run -v /var/run/mysqld:/mariadb_socket ... tuxgasy/dolibarr



                  Then connect to mariadb via the socket /mariadb_socket/mysqld.sock from your app



                3. Use the docker host's ip. First get the host ip address on the docker network (in linux type
                  ip addr show and look for the docker0 ip). This is usually something like 172.17.0.1 (your mileage may vary).
                  Then you should be able to use that ip address to connect to mariadb for example 172.17.0.1:3306



                NOTE: ... means any other options that you may already be using






                share|improve this answer




























                  4












                  4








                  4







                  There are three ways:





                  1. Use the --net=host option. This network mode essentially means that the container has direct access to localhost and you can now access localhost:3306. Here's the command



                    docker run --net=host ... tuxgasy/dolibarr



                    Then connect to mariadb with localhost:3306




                  2. Mount the mariadb socket to the docker container and connect to mariadb via socket. For example if you configure the socket's location to be /var/run/mysqld/mysqld.sock then you could mount and use that as your connection point.



                    docker run -v /var/run/mysqld:/mariadb_socket ... tuxgasy/dolibarr



                    Then connect to mariadb via the socket /mariadb_socket/mysqld.sock from your app



                  3. Use the docker host's ip. First get the host ip address on the docker network (in linux type
                    ip addr show and look for the docker0 ip). This is usually something like 172.17.0.1 (your mileage may vary).
                    Then you should be able to use that ip address to connect to mariadb for example 172.17.0.1:3306



                  NOTE: ... means any other options that you may already be using






                  share|improve this answer















                  There are three ways:





                  1. Use the --net=host option. This network mode essentially means that the container has direct access to localhost and you can now access localhost:3306. Here's the command



                    docker run --net=host ... tuxgasy/dolibarr



                    Then connect to mariadb with localhost:3306




                  2. Mount the mariadb socket to the docker container and connect to mariadb via socket. For example if you configure the socket's location to be /var/run/mysqld/mysqld.sock then you could mount and use that as your connection point.



                    docker run -v /var/run/mysqld:/mariadb_socket ... tuxgasy/dolibarr



                    Then connect to mariadb via the socket /mariadb_socket/mysqld.sock from your app



                  3. Use the docker host's ip. First get the host ip address on the docker network (in linux type
                    ip addr show and look for the docker0 ip). This is usually something like 172.17.0.1 (your mileage may vary).
                    Then you should be able to use that ip address to connect to mariadb for example 172.17.0.1:3306



                  NOTE: ... means any other options that you may already be using







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Oct 8 '17 at 10:59

























                  answered Oct 8 '17 at 10:53









                  Clive MakamaraClive Makamara

                  1965




                  1965

























                      0














                      I've created a docker container for doing exactly that https://github.com/qoomon/docker-host



                      You can then simply use container name dns to access host system from inside a container e.g. curl http://dockerhost:9200






                      share|improve this answer




























                        0














                        I've created a docker container for doing exactly that https://github.com/qoomon/docker-host



                        You can then simply use container name dns to access host system from inside a container e.g. curl http://dockerhost:9200






                        share|improve this answer


























                          0












                          0








                          0







                          I've created a docker container for doing exactly that https://github.com/qoomon/docker-host



                          You can then simply use container name dns to access host system from inside a container e.g. curl http://dockerhost:9200






                          share|improve this answer













                          I've created a docker container for doing exactly that https://github.com/qoomon/docker-host



                          You can then simply use container name dns to access host system from inside a container e.g. curl http://dockerhost:9200







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Dec 26 '18 at 21:35









                          qoomonqoomon

                          1414




                          1414






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Super User!


                              • 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%2fsuperuser.com%2fquestions%2f1254515%2fsetup-a-docker-container-to-work-with-a-local-database%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

                              Plaza Victoria

                              In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

                              How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...