Cannot connect to docker0 (MongoDB chart)









up vote
0
down vote

favorite












I am completely new to docker. I followed this instruction to install mongodb chart and docker.



When I connect to 172.17.0.1, it said



Unable to connect to MongoDB using the specified URI.

The following error was returned while attempting to connect:
MongoNetworkError: failed to connect to server [172.17.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 172.17.0.1:27017]

The result from pinging the specified server "172.17.0.1" from within the container is:
PING 172.17.0.1 (172.17.0.1) 56(84) bytes of data.
64 bytes from 172.17.0.1: icmp_seq=1 ttl=64 time=0.050 ms

--- 172.17.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.050/0.050/0.050/0.000 ms


The mongodb is running on local machine. I think it is not running in the container (not sure) because I installed mongodb in my machine before I install docker.



I have also checked the setting by using docker network inspect bridge



"Config": [

"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"

]


This is the yml file:



version: "3.3"

services:
charts:
image: quay.io/mongodb/charts:v0.10.0
hostname: charts
ports:
# host:container port mapping. If you want MongoDB Charts to be
# reachable on a different port on the docker host, change this
# to <port>:80, e.g. 8888:80.
- 80:80
- 443:443
volumes:
- keys:/mongodb-charts/volumes/keys
- logs:/mongodb-charts/volumes/logs
- db-certs:/mongodb-charts/volumes/db-certs
- web-certs:/mongodb-charts/volumes/web-certs
environment:
# The presence of following 2 environment variables will enable HTTPS on Charts server.
# All HTTP requests will be redirected to HTTPS as well.
# To enable HTTPS, upload your certificate and key file to the web-certs volume,
# uncomment the following lines and replace with the names of your certificate and key file.
# CHARTS_HTTPS_CERTIFICATE_FILE: charts-https.crt
# CHARTS_HTTPS_CERTIFICATE_KEY_FILE: charts-https.key

# This environment variable controls the built-in support widget and
# metrics collection in MongoDB Charts. To disable both, set the value
# to "off". The default is "on".
CHARTS_SUPPORT_WIDGET_AND_METRICS: "on"
# Directory where you can upload SSL certificates (.pem format) which
# should be considered trusted self-signed or root certificates when
# Charts is accessing MongoDB servers with ?ssl=true
SSL_CERT_DIR: /mongodb-charts/volumes/db-certs
networks:
- backend
secrets:
- charts-mongodb-uri

networks:
backend:

volumes:
keys:
logs:
db-certs:
web-certs:

secrets:
charts-mongodb-uri:
external: true


How can I connect to the mongodb?










share|improve this question



















  • 1




    Where is MongoDB running? (Directly on the host?) Where are you trying to connect from? (Some other Docker container?) How did you start it; can you share your docker run command or docker-compose.yml file?
    – David Maze
    Nov 10 at 16:48










  • @DavidMaze updated. Thanks!
    – JOHN
    Nov 11 at 0:23














up vote
0
down vote

favorite












I am completely new to docker. I followed this instruction to install mongodb chart and docker.



When I connect to 172.17.0.1, it said



Unable to connect to MongoDB using the specified URI.

The following error was returned while attempting to connect:
MongoNetworkError: failed to connect to server [172.17.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 172.17.0.1:27017]

The result from pinging the specified server "172.17.0.1" from within the container is:
PING 172.17.0.1 (172.17.0.1) 56(84) bytes of data.
64 bytes from 172.17.0.1: icmp_seq=1 ttl=64 time=0.050 ms

--- 172.17.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.050/0.050/0.050/0.000 ms


The mongodb is running on local machine. I think it is not running in the container (not sure) because I installed mongodb in my machine before I install docker.



I have also checked the setting by using docker network inspect bridge



"Config": [

"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"

]


This is the yml file:



version: "3.3"

services:
charts:
image: quay.io/mongodb/charts:v0.10.0
hostname: charts
ports:
# host:container port mapping. If you want MongoDB Charts to be
# reachable on a different port on the docker host, change this
# to <port>:80, e.g. 8888:80.
- 80:80
- 443:443
volumes:
- keys:/mongodb-charts/volumes/keys
- logs:/mongodb-charts/volumes/logs
- db-certs:/mongodb-charts/volumes/db-certs
- web-certs:/mongodb-charts/volumes/web-certs
environment:
# The presence of following 2 environment variables will enable HTTPS on Charts server.
# All HTTP requests will be redirected to HTTPS as well.
# To enable HTTPS, upload your certificate and key file to the web-certs volume,
# uncomment the following lines and replace with the names of your certificate and key file.
# CHARTS_HTTPS_CERTIFICATE_FILE: charts-https.crt
# CHARTS_HTTPS_CERTIFICATE_KEY_FILE: charts-https.key

# This environment variable controls the built-in support widget and
# metrics collection in MongoDB Charts. To disable both, set the value
# to "off". The default is "on".
CHARTS_SUPPORT_WIDGET_AND_METRICS: "on"
# Directory where you can upload SSL certificates (.pem format) which
# should be considered trusted self-signed or root certificates when
# Charts is accessing MongoDB servers with ?ssl=true
SSL_CERT_DIR: /mongodb-charts/volumes/db-certs
networks:
- backend
secrets:
- charts-mongodb-uri

networks:
backend:

volumes:
keys:
logs:
db-certs:
web-certs:

secrets:
charts-mongodb-uri:
external: true


How can I connect to the mongodb?










share|improve this question



















  • 1




    Where is MongoDB running? (Directly on the host?) Where are you trying to connect from? (Some other Docker container?) How did you start it; can you share your docker run command or docker-compose.yml file?
    – David Maze
    Nov 10 at 16:48










  • @DavidMaze updated. Thanks!
    – JOHN
    Nov 11 at 0:23












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am completely new to docker. I followed this instruction to install mongodb chart and docker.



When I connect to 172.17.0.1, it said



Unable to connect to MongoDB using the specified URI.

The following error was returned while attempting to connect:
MongoNetworkError: failed to connect to server [172.17.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 172.17.0.1:27017]

The result from pinging the specified server "172.17.0.1" from within the container is:
PING 172.17.0.1 (172.17.0.1) 56(84) bytes of data.
64 bytes from 172.17.0.1: icmp_seq=1 ttl=64 time=0.050 ms

--- 172.17.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.050/0.050/0.050/0.000 ms


The mongodb is running on local machine. I think it is not running in the container (not sure) because I installed mongodb in my machine before I install docker.



I have also checked the setting by using docker network inspect bridge



"Config": [

"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"

]


This is the yml file:



version: "3.3"

services:
charts:
image: quay.io/mongodb/charts:v0.10.0
hostname: charts
ports:
# host:container port mapping. If you want MongoDB Charts to be
# reachable on a different port on the docker host, change this
# to <port>:80, e.g. 8888:80.
- 80:80
- 443:443
volumes:
- keys:/mongodb-charts/volumes/keys
- logs:/mongodb-charts/volumes/logs
- db-certs:/mongodb-charts/volumes/db-certs
- web-certs:/mongodb-charts/volumes/web-certs
environment:
# The presence of following 2 environment variables will enable HTTPS on Charts server.
# All HTTP requests will be redirected to HTTPS as well.
# To enable HTTPS, upload your certificate and key file to the web-certs volume,
# uncomment the following lines and replace with the names of your certificate and key file.
# CHARTS_HTTPS_CERTIFICATE_FILE: charts-https.crt
# CHARTS_HTTPS_CERTIFICATE_KEY_FILE: charts-https.key

# This environment variable controls the built-in support widget and
# metrics collection in MongoDB Charts. To disable both, set the value
# to "off". The default is "on".
CHARTS_SUPPORT_WIDGET_AND_METRICS: "on"
# Directory where you can upload SSL certificates (.pem format) which
# should be considered trusted self-signed or root certificates when
# Charts is accessing MongoDB servers with ?ssl=true
SSL_CERT_DIR: /mongodb-charts/volumes/db-certs
networks:
- backend
secrets:
- charts-mongodb-uri

networks:
backend:

volumes:
keys:
logs:
db-certs:
web-certs:

secrets:
charts-mongodb-uri:
external: true


How can I connect to the mongodb?










share|improve this question















I am completely new to docker. I followed this instruction to install mongodb chart and docker.



When I connect to 172.17.0.1, it said



Unable to connect to MongoDB using the specified URI.

The following error was returned while attempting to connect:
MongoNetworkError: failed to connect to server [172.17.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 172.17.0.1:27017]

The result from pinging the specified server "172.17.0.1" from within the container is:
PING 172.17.0.1 (172.17.0.1) 56(84) bytes of data.
64 bytes from 172.17.0.1: icmp_seq=1 ttl=64 time=0.050 ms

--- 172.17.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.050/0.050/0.050/0.000 ms


The mongodb is running on local machine. I think it is not running in the container (not sure) because I installed mongodb in my machine before I install docker.



I have also checked the setting by using docker network inspect bridge



"Config": [

"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"

]


This is the yml file:



version: "3.3"

services:
charts:
image: quay.io/mongodb/charts:v0.10.0
hostname: charts
ports:
# host:container port mapping. If you want MongoDB Charts to be
# reachable on a different port on the docker host, change this
# to <port>:80, e.g. 8888:80.
- 80:80
- 443:443
volumes:
- keys:/mongodb-charts/volumes/keys
- logs:/mongodb-charts/volumes/logs
- db-certs:/mongodb-charts/volumes/db-certs
- web-certs:/mongodb-charts/volumes/web-certs
environment:
# The presence of following 2 environment variables will enable HTTPS on Charts server.
# All HTTP requests will be redirected to HTTPS as well.
# To enable HTTPS, upload your certificate and key file to the web-certs volume,
# uncomment the following lines and replace with the names of your certificate and key file.
# CHARTS_HTTPS_CERTIFICATE_FILE: charts-https.crt
# CHARTS_HTTPS_CERTIFICATE_KEY_FILE: charts-https.key

# This environment variable controls the built-in support widget and
# metrics collection in MongoDB Charts. To disable both, set the value
# to "off". The default is "on".
CHARTS_SUPPORT_WIDGET_AND_METRICS: "on"
# Directory where you can upload SSL certificates (.pem format) which
# should be considered trusted self-signed or root certificates when
# Charts is accessing MongoDB servers with ?ssl=true
SSL_CERT_DIR: /mongodb-charts/volumes/db-certs
networks:
- backend
secrets:
- charts-mongodb-uri

networks:
backend:

volumes:
keys:
logs:
db-certs:
web-certs:

secrets:
charts-mongodb-uri:
external: true


How can I connect to the mongodb?







mongodb docker






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 0:18

























asked Nov 10 at 15:48









JOHN

163313




163313







  • 1




    Where is MongoDB running? (Directly on the host?) Where are you trying to connect from? (Some other Docker container?) How did you start it; can you share your docker run command or docker-compose.yml file?
    – David Maze
    Nov 10 at 16:48










  • @DavidMaze updated. Thanks!
    – JOHN
    Nov 11 at 0:23












  • 1




    Where is MongoDB running? (Directly on the host?) Where are you trying to connect from? (Some other Docker container?) How did you start it; can you share your docker run command or docker-compose.yml file?
    – David Maze
    Nov 10 at 16:48










  • @DavidMaze updated. Thanks!
    – JOHN
    Nov 11 at 0:23







1




1




Where is MongoDB running? (Directly on the host?) Where are you trying to connect from? (Some other Docker container?) How did you start it; can you share your docker run command or docker-compose.yml file?
– David Maze
Nov 10 at 16:48




Where is MongoDB running? (Directly on the host?) Where are you trying to connect from? (Some other Docker container?) How did you start it; can you share your docker run command or docker-compose.yml file?
– David Maze
Nov 10 at 16:48












@DavidMaze updated. Thanks!
– JOHN
Nov 11 at 0:23




@DavidMaze updated. Thanks!
– JOHN
Nov 11 at 0:23












1 Answer
1






active

oldest

votes

















up vote
0
down vote













Assuming you know how to use echo "mongodb://<username>:<password>@myhost.com/" | docker secret create charts-mongodb-uri - to create the connection the url.



The problem is actually how to connect from a docker container to a outside service running on the host machine. You can use some help from plenty of questions like From inside of a Docker container, how do I connect to the localhost of the machine?



Basically, if you are using docker for mac or windows, use something like echo "mongodb://host.docker.internal" | docker secret create charts-mongodb-uri -, for linux see https://docs.mongodb.com/charts/master/installation/ section RUNNING METADATA DATABASE ON LOCALHOST for the doc, or just use host mode (remove ports section)



version: "3.3"
services:
charts:
image: quay.io/mongodb/charts:v0.10.0
hostname: charts
network_mode: "host"
...





share|improve this answer






















  • I have tried: docker run --rm quay.io/mongodb/charts:v0.10.0 charts-cli test-connection mongodb://172.17.0.1 in linux but not working.
    – JOHN
    Nov 11 at 2:26






  • 1




    I need to set bindIP = 0.0.0.0
    – JOHN
    Nov 11 at 9:32






  • 1




    askubuntu.com/questions/941816/… I also needed to do sudo chmod a+rwx /var/run/docker.sock sudo chmod a+rwx /var/run/docker.pid to get permission
    – JOHN
    Nov 11 at 9:39










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',
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%2f53240613%2fcannot-connect-to-docker0-mongodb-chart%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








up vote
0
down vote













Assuming you know how to use echo "mongodb://<username>:<password>@myhost.com/" | docker secret create charts-mongodb-uri - to create the connection the url.



The problem is actually how to connect from a docker container to a outside service running on the host machine. You can use some help from plenty of questions like From inside of a Docker container, how do I connect to the localhost of the machine?



Basically, if you are using docker for mac or windows, use something like echo "mongodb://host.docker.internal" | docker secret create charts-mongodb-uri -, for linux see https://docs.mongodb.com/charts/master/installation/ section RUNNING METADATA DATABASE ON LOCALHOST for the doc, or just use host mode (remove ports section)



version: "3.3"
services:
charts:
image: quay.io/mongodb/charts:v0.10.0
hostname: charts
network_mode: "host"
...





share|improve this answer






















  • I have tried: docker run --rm quay.io/mongodb/charts:v0.10.0 charts-cli test-connection mongodb://172.17.0.1 in linux but not working.
    – JOHN
    Nov 11 at 2:26






  • 1




    I need to set bindIP = 0.0.0.0
    – JOHN
    Nov 11 at 9:32






  • 1




    askubuntu.com/questions/941816/… I also needed to do sudo chmod a+rwx /var/run/docker.sock sudo chmod a+rwx /var/run/docker.pid to get permission
    – JOHN
    Nov 11 at 9:39














up vote
0
down vote













Assuming you know how to use echo "mongodb://<username>:<password>@myhost.com/" | docker secret create charts-mongodb-uri - to create the connection the url.



The problem is actually how to connect from a docker container to a outside service running on the host machine. You can use some help from plenty of questions like From inside of a Docker container, how do I connect to the localhost of the machine?



Basically, if you are using docker for mac or windows, use something like echo "mongodb://host.docker.internal" | docker secret create charts-mongodb-uri -, for linux see https://docs.mongodb.com/charts/master/installation/ section RUNNING METADATA DATABASE ON LOCALHOST for the doc, or just use host mode (remove ports section)



version: "3.3"
services:
charts:
image: quay.io/mongodb/charts:v0.10.0
hostname: charts
network_mode: "host"
...





share|improve this answer






















  • I have tried: docker run --rm quay.io/mongodb/charts:v0.10.0 charts-cli test-connection mongodb://172.17.0.1 in linux but not working.
    – JOHN
    Nov 11 at 2:26






  • 1




    I need to set bindIP = 0.0.0.0
    – JOHN
    Nov 11 at 9:32






  • 1




    askubuntu.com/questions/941816/… I also needed to do sudo chmod a+rwx /var/run/docker.sock sudo chmod a+rwx /var/run/docker.pid to get permission
    – JOHN
    Nov 11 at 9:39












up vote
0
down vote










up vote
0
down vote









Assuming you know how to use echo "mongodb://<username>:<password>@myhost.com/" | docker secret create charts-mongodb-uri - to create the connection the url.



The problem is actually how to connect from a docker container to a outside service running on the host machine. You can use some help from plenty of questions like From inside of a Docker container, how do I connect to the localhost of the machine?



Basically, if you are using docker for mac or windows, use something like echo "mongodb://host.docker.internal" | docker secret create charts-mongodb-uri -, for linux see https://docs.mongodb.com/charts/master/installation/ section RUNNING METADATA DATABASE ON LOCALHOST for the doc, or just use host mode (remove ports section)



version: "3.3"
services:
charts:
image: quay.io/mongodb/charts:v0.10.0
hostname: charts
network_mode: "host"
...





share|improve this answer














Assuming you know how to use echo "mongodb://<username>:<password>@myhost.com/" | docker secret create charts-mongodb-uri - to create the connection the url.



The problem is actually how to connect from a docker container to a outside service running on the host machine. You can use some help from plenty of questions like From inside of a Docker container, how do I connect to the localhost of the machine?



Basically, if you are using docker for mac or windows, use something like echo "mongodb://host.docker.internal" | docker secret create charts-mongodb-uri -, for linux see https://docs.mongodb.com/charts/master/installation/ section RUNNING METADATA DATABASE ON LOCALHOST for the doc, or just use host mode (remove ports section)



version: "3.3"
services:
charts:
image: quay.io/mongodb/charts:v0.10.0
hostname: charts
network_mode: "host"
...






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 11 at 0:59

























answered Nov 11 at 0:45









Siyu

804416




804416











  • I have tried: docker run --rm quay.io/mongodb/charts:v0.10.0 charts-cli test-connection mongodb://172.17.0.1 in linux but not working.
    – JOHN
    Nov 11 at 2:26






  • 1




    I need to set bindIP = 0.0.0.0
    – JOHN
    Nov 11 at 9:32






  • 1




    askubuntu.com/questions/941816/… I also needed to do sudo chmod a+rwx /var/run/docker.sock sudo chmod a+rwx /var/run/docker.pid to get permission
    – JOHN
    Nov 11 at 9:39
















  • I have tried: docker run --rm quay.io/mongodb/charts:v0.10.0 charts-cli test-connection mongodb://172.17.0.1 in linux but not working.
    – JOHN
    Nov 11 at 2:26






  • 1




    I need to set bindIP = 0.0.0.0
    – JOHN
    Nov 11 at 9:32






  • 1




    askubuntu.com/questions/941816/… I also needed to do sudo chmod a+rwx /var/run/docker.sock sudo chmod a+rwx /var/run/docker.pid to get permission
    – JOHN
    Nov 11 at 9:39















I have tried: docker run --rm quay.io/mongodb/charts:v0.10.0 charts-cli test-connection mongodb://172.17.0.1 in linux but not working.
– JOHN
Nov 11 at 2:26




I have tried: docker run --rm quay.io/mongodb/charts:v0.10.0 charts-cli test-connection mongodb://172.17.0.1 in linux but not working.
– JOHN
Nov 11 at 2:26




1




1




I need to set bindIP = 0.0.0.0
– JOHN
Nov 11 at 9:32




I need to set bindIP = 0.0.0.0
– JOHN
Nov 11 at 9:32




1




1




askubuntu.com/questions/941816/… I also needed to do sudo chmod a+rwx /var/run/docker.sock sudo chmod a+rwx /var/run/docker.pid to get permission
– JOHN
Nov 11 at 9:39




askubuntu.com/questions/941816/… I also needed to do sudo chmod a+rwx /var/run/docker.sock sudo chmod a+rwx /var/run/docker.pid to get permission
– JOHN
Nov 11 at 9:39

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240613%2fcannot-connect-to-docker0-mongodb-chart%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

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

政党