Setup a Docker container to work with a local database
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
add a comment |
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
add a comment |
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
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
linux database docker opensuse mariadb
asked Sep 28 '17 at 15:04
SekhemtySekhemty
3,909104480
3,909104480
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
There are three ways:
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
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
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 example172.17.0.1:3306
NOTE: ... means any other options that you may already be using
add a comment |
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
There are three ways:
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
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
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 example172.17.0.1:3306
NOTE: ... means any other options that you may already be using
add a comment |
There are three ways:
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
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
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 example172.17.0.1:3306
NOTE: ... means any other options that you may already be using
add a comment |
There are three ways:
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
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
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 example172.17.0.1:3306
NOTE: ... means any other options that you may already be using
There are three ways:
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
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
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 example172.17.0.1:3306
NOTE: ... means any other options that you may already be using
edited Oct 8 '17 at 10:59
answered Oct 8 '17 at 10:53
Clive MakamaraClive Makamara
1965
1965
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Dec 26 '18 at 21:35
qoomonqoomon
1414
1414
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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