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?
mongodb docker
add a comment |
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?
mongodb docker
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 yourdocker run
command ordocker-compose.yml
file?
– David Maze
Nov 10 at 16:48
@DavidMaze updated. Thanks!
– JOHN
Nov 11 at 0:23
add a comment |
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?
mongodb docker
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
mongodb docker
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 yourdocker run
command ordocker-compose.yml
file?
– David Maze
Nov 10 at 16:48
@DavidMaze updated. Thanks!
– JOHN
Nov 11 at 0:23
add a comment |
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 yourdocker run
command ordocker-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
add a comment |
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"
...
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
add a comment |
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"
...
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
add a comment |
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"
...
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
add a comment |
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"
...
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"
...
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
add a comment |
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
add a comment |
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%2fstackoverflow.com%2fquestions%2f53240613%2fcannot-connect-to-docker0-mongodb-chart%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
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 ordocker-compose.yml
file?– David Maze
Nov 10 at 16:48
@DavidMaze updated. Thanks!
– JOHN
Nov 11 at 0:23