[英]Connection Refused on MongoDB Docker Container from Flask Docker Container
[英]Connection refused in mongodb macvlan docker container
我有一个安装了 docker 并在 macvlan 模式下安装了 mongo Docker 的树莓派 Pi4。
And from my desktop computer I ping the docker IP and response well, but when I try to access the mongodb server with other docker in this computer, it fails.
无法从存在 macvlan 的同一网络中的其他 docker 连接。
这是我的 docker 网络检查 output:
pi@raspberrypi:~ $ docker network inspect pablo1
[
"ConfigOnly": false,
"Containers": {
"f17210b2cf26b2752e03b2a4c889041ab9be3a8746675e29e2104362409c8039": {
"Name": "mongo",
"EndpointID": "6aedeff51378d8a8f5f6ebc7533306edcd21a3324f5dff319e5bbed5736df5d4",
"MacAddress": "02:42:c0:a8:00:c4",
"IPv4Address": "192.168.0.196/24",
"IPv6Address": ""
}
},
"Options": {
"parent": "eth0"
},
"Labels": {}
}
]
这是我的 Dockerfile 来制作 Docker 容器:
FROM armv7/armhf-ubuntu:16.04
RUN apt-get update && \
apt-get install -y mongodb
RUN apt-get dist-upgrade -y && \
apt-get autoremove -y && \
apt-get autoclean -y && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
# Environment variables
RUN echo " " >> /etc/bash.bashrc && \
echo "#_____________________" >> /etc/bash.bashrc && \
echo "force_color_prompt=yes" >> /etc/bash.bashrc && \
echo "alias cls='clear'" >> /etc/bash.bashrc && \
echo "export TERM=linux" >> /etc/bash.bashrc
# Define mountable directories.
VOLUME ["/data/db"]
# Define working directory.
WORKDIR /data
COPY mongodb.conf /etc/
# Define default command.
# Expose ports.
# - 27017: process
# - 28017: http
RUN cat /etc/mongodb.conf
RUN ls -las /etc
CMD ["mongod"]
EXPOSE 27017
EXPOSE 28017
这是 Docker mongodb mongodb.conf 的一部分
# mongodb.conf
# Where to store the data.
dbpath=/var/lib/mongodb
#where to log
logpath=/var/log/mongodb/mongodb.log
logappend=true
bind_ip = 0.0.0.0
port = 27017
抱歉,只有当数据库目录挂载在NFS外部分区时才会出现这个问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.