I'm running the standard mongodb container (with a modified docker entrypoint and config) I've tried change the config file and start up script to work with with my IPv6 address or :: (all/any) I've tried including --ipv6 which different posts say is either needed or no longer used. It also seems that when the mongo config tried to bind to all ipv6 addresses I loose internet connectivity for the entire container (can't use apt update).
docker command:
docker run -d -v /Docker/entrypoint/:/usr/local/bin/ -v /Docker/mongoconfig/mongod.conf.orig:/etc/mongod.conf.orig -p 27017:27017 mongo:5.0.3
I've tried with different docker entrypoint code.
try 1 docker-entrypoint.sh:
#!/bin/bash
exec mongod --bind_ip '::' --ipv6
try 2 docker-entrypoint.sh:
#!/bin/bash
exec mongod --bind_ip [134:1234:134:1324:1234:134:1234:3]
try 3 docker-entrypoint.sh:
#!/bin/bash
exec mongod --bind_ip [134:1234:134:1324:1234:134:1234:3] --ipv6
try 4 docker-entrypoint.sh:
#!/bin/bash
exec mongod --bind_ip_all
the mongo config pretty much stayed the same swapping the bind IP and ipv6 by commenting out as seen here:
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
#bindIp: 134:1234:134:1324:1234:134:1234:3
bind_ip = 0::0
ipv6 = true
ps -auxwe output
root 1 0.8 5.4 1540940 111092 ? Ssl 09:38 0:01 mongod --bind_ip :: --ipv6 HOSTNAME=6cb245ebc947 PWD=/ HOME=/root MONGO_PACKAGE=mongodb-org
netstat output
netstat -anp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 172.17.0.3:45684 91.189.88.152:80 TIME_WAIT -
tcp 0 0 172.17.0.3:39324 91.189.91.38:80 TIME_WAIT -
tcp 0 0 172.17.0.3:54468 91.189.88.142:80 TIME_WAIT -
tcp 0 0 172.17.0.3:40844 13.227.219.90:80 TIME_WAIT -
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 1635933 1/mongod /tmp/mongodb-27017.sock
mongoshell:
mongo --ipv6 [134:1234:134:1324:1234:134:1234:3]:27017/local
MongoDB shell version v5.0.3
connecting to: mongodb://[134%31234%3134%31324%31234%3134%31234%33]:27017/local?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server [134:1234:134:1324:1234:134:1234:3]:27017, connection attempt failed: SocketException: Error connecting to [134:1234:134:1324:1234:134:1234:3]:27017 (134:1234:134:1324:1234:134:1234:3:27017) :: caused by :: No route to host :
connect@src/mongo/shell/mongo.js:372:17
when I passed only --ipv6 to the entrypoint my netstat did acknowledge mongo listeningmongod --ipv6
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 1/mongod
tcp6 0 0 ::1:27017 :::* LISTEN 1/mongod
