示例
如下是為容器設置固定IP的 docker-compose.yml
示例,其中包含定義 networks
和在應用中引用設定固定 IP 的配置。
version: '3.9'
services:
coredns:
image: coredns/coredns:1.10.0
container_name: coredns
ports:
- 53:53/udp
networks:
mynetwork:
ipv4_address: 172.28.0.4
volumes:
- ./coredns/hostsfile:/etc/coredns/hostsfile
- ./coredns/Corefile:/Corefile
networks:
mynetwork:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.28.0.0/16
gateway: 172.28.0.1
參考官網鏈接:文章來源:http://www.zghlxwxcb.cn/news/detail-541097.html
- https://docs.docker.com/compose/compose-file/#ipam
- https://github.com/docker/compose/issues/4336
(END)文章來源地址http://www.zghlxwxcb.cn/news/detail-541097.html
到了這里,關于docker-compose 容器固定IP(network subnet)的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!