我正在尝试实施本教程。 “docker-compose”的内容是这样的:
# WARNING: Do not deploy this tutorial configuration directly to a production environment
#
# The tutorial docker-compose files have not been written for production deployment and will not
# scale. A proper architecture has been sacrificed to keep the narrative focused on the learning
# goals, they are just used to deploy everything onto a single Docker machine. All FIWARE components
# are running at full debug and extra ports have been exposed to allow for direct calls to services.
# They also contain various obvious security flaws - passwords in plain text, no load balancing,
# no use of HTTPS and so on.
#
# This is all to avoid the need of multiple machines, generating certificates, encrypting secrets
# and so on, purely so that a single docker-compose file can be read as an example to build on,
# not use directly.
#
# When deploying to a production environment, please refer to the Helm Repository
# for FIWARE Components in order to scale up to a proper architecture:
#
# see: https://github.com/FIWARE/helm-charts/
#
version: "3.5"
services:
# Orion is the context broker
orion:
image: fiware/orion:latest
hostname: orion
container_name: fiware-orion
depends_on:
- mongo-db
networks:
- default
expose:
- "1026"
ports:
- "1026:1026"
command: -dbhost mongo-db -logLevel DEBUG
healthcheck:
test: curl --fail -s http://orion:1026/version || exit 1
interval: 5s
# Tutorial displays a web app to manipulate the context directly
tutorial:
image: fiware/tutorials.context-provider
hostname: iot-sensors
container_name: fiware-tutorial
networks:
- default
expose:
- "3000"
- "3001"
ports:
- "3000:3000"
- "3001:3001"
environment:
- "DEBUG=tutorial:*"
- "PORT=3000"
- "IOTA_HTTP_HOST=iot-agent"
- "IOTA_HTTP_PORT=7896"
- "DUMMY_DEVICES_PORT=3001"
- "DUMMY_DEVICES_API_KEY=4jggokgpepnvsb2uv4s40d59ov"
- "DUMMY_DEVICES_TRANSPORT=HTTP"
iot-agent:
image: fiware/iotagent-ul:latest
hostname: iot-agent
container_name: fiware-iot-agent
depends_on:
- mongo-db
networks:
- default
expose:
- "4041"
- "7896"
ports:
- "4041:4041"
- "7896:7896"
environment:
- "IOTA_CB_HOST=orion"
- "IOTA_CB_PORT=1026"
- "IOTA_NORTH_PORT=4041"
- "IOTA_REGISTRY_TYPE=mongodb"
- "IOTA_LOG_LEVEL=DEBUG"
- "IOTA_TIMESTAMP=true"
- "IOTA_MONGO_HOST=mongo-db"
- "IOTA_MONGO_PORT=27017"
- "IOTA_MONGO_DB=iotagentul"
- "IOTA_HTTP_PORT=7896"
- "IOTA_PROVIDER_URL=http://iot-agent:4041"
# Database
mongo-db:
image: mongo:3.6
hostname: mongo-db
container_name: db-mongo
expose:
- "27017"
ports:
- "27017:27017"
networks:
- default
command: --bind_ip_all --smallfiles
volumes:
- mongo-db:/data
healthcheck:
test: |
host=`hostname --ip-address || echo '127.0.0.1'`;
mongo --quiet $host/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)' && echo 0 || echo 1
interval: 5s
networks:
default:
ipam:
config:
- subnet: 172.18.1.0/24
volumes:
mongo-db: ~
但是当我使用命令“docker-compose up -d”运行 docker compose 时,我得到了这个错误:
*WARNING: The host variable is not set. Defaulting to a blank string.
Creating network "fiware_default" with the default driver
ERROR: Pool overlaps with other one on this address space*
我还通过运行命令“docker network ls”获得这些网络:
*NETWORK ID NAME DRIVER SCOPE
78403834b9bd bridge bridge local
1dc5b7d0534b hadig_default bridge local
4162244c37b0 host host local
ac5a94a89bde none null local*
我发现与名称“fiware_default”没有冲突。问题出在哪里?
报错信息所指的“pool”是文件手动指定的172.18.1.0/24网段。如果您系统上的其他东西正在使用该网络空间,它就不会启动。 (例如,Docker 可能已将另一个 Compose 文件的网络分配给 172.18.0.0/16。)
您通常根本不需要在 Docker 中手动指定 IP 地址,因此您应该删除该
ipam:
块。完成后,您将告诉 Compose 使用默认设置配置 default
网络,实际上您可以删除文件末尾的整个 networks:
块。
例外情况是,如果您的主机网络环境正在使用一些相同的 IP 地址块,那么您可能确实需要这样的覆盖。如果您从主机运行
ifconfig
或类似命令(或从桌面应用程序查看主机的网络设置)并且您的主机或 VPN 使用 172.18.1.* 地址,您也会收到此消息。在这种情况下,将网络更改为其他网络;如果你只需要一个/24(254个地址)然后设置subnet: 192.168.123.0/24
(其中“123”可以是1到254之间的任何数字)应该让你通过这个。
来自守护进程的错误响应:网络池与该地址空间上的另一个重叠。
在我的例子中,我有一个带有硬编码网络 IP 地址的 docker-compose.yaml 文件,另一个容器使用相同的网络启动。
networks:
vpn-net:
ipv4_address: 172.21.0.2
要解决这个问题,首先,找到当前正在使用它的容器:
# docker network ls
NETWORK ID NAME DRIVER SCOPE
ca9b2b29a253 bridge bridge local
45e9488d9140 host host local
5966656f9981 none null local
b3edda2ed475 my-service-net bridge local
a9eb7c1f3d20 another-network bridge local
# docker inspect my-service-net | grep 172.21.0.2
"IPv4Address": "172.21.0.2/16"
停止找到的网络服务:
# docker stop my-service-net
最后,启动失败的新容器。您也可以删除 IP 网络配置或更改 IP。