我是 docker-compose 的新手,正在尝试创建以下内容。我家里的网络是 192.168.1.0/24 网络。我有一台安装了 docker 的树莓派,IP 为 192.168.1.50
我想创建 2 个容器,就像 PiHole 和 Unbound 一样。我想通过 192.168.1.200 地址访问 Pihole。我还为 PiHole 和 Adguard 之间的通信创建了一座桥梁。当我启动 docker compose 文件时,我收到一个错误:
reating network "dockerfiles_mvltest" with driver "macvlan"
Creating network "dockerfiles_brdtest" with driver "bridge"
Creating pihole ... error
Creating unbound ...
Creating unbound ... done
ERROR: for pihole Cannot start service pihole: Address already in use
ERROR: Encountered errors while bringing up the project.
docker-compose.yaml 文件如下所示:
version: '3'
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
# cap_add: # Uncomment if you want to use Pi-Hole for DHCP
# - NET_ADMIN
ports:
- 53/tcp
- 53/udp
# - 67/udp # Uncomment if you want to use Pi-Hole for DHCP
- 80/tcp
environment:
- FTLCONF_LOCAL_IPV4=192.168.1.200
- WEBPASSWORD=Welkom123
- PIHOLE_DNS_=10.1.0.2
- TZ=Europe/Amsterdam
- DNSMASQ_USER=root
- DNSMASQ_LISTENING=local
volumes:
- ./pihole/data:/etc/pihole:rw
- ./pihole/dnsmasq.d:/etc/dnsmasq.d/:rw
networks:
mvltest:
ipv4_address: 192.168.1.200
brdtest:
ipv4_address: 10.1.0.1
restart: always
unbound:
container_name: unbound
image: mvance/unbound:latest
ports:
- 53/tcp
- 53/udp
networks:
brdtest:
ipv4_address: 10.1.0.2
restart: always
networks:
mvltest:
driver: macvlan
driver_opts:
parent: ens33
ipam:
config:
- subnet: 192.168.1.0/24
gateway: 192.168.1.254
brdtest:
driver: bridge
ipam:
config:
- subnet: 10.1.0.0/30
我究竟做错了什么?
我希望这个构造能够起作用。我在 youtube 上找到了这个示例。