[英]How should I rewrite docker-compose.yaml for Kubernetes?
[英]Can I create a docker-compose.yaml that only creates networks?
我有一組用於創建服務和自定義網絡的 docker-compose 文件。 一些撰寫文件在其他文件中引用網絡。
例如。:
version: '2.2'
services:
(...)
volumes:
(...)
networks:
management:
driver: macvlan
driver_opts:
parent: enp1s0.10
ipam:
config:
- subnet: 192.168.10.0/24
home:
driver: macvlan
driver_opts:
parent: enp1s0
ipam:
config:
- subnet: 192.168.3.0/24
gateway: 192.168.3.1
這個 compose 文件創建了幾個服務和兩個網絡。
現在我有另一個 compose 文件,它也使用其中一個網絡,並創建另一個自己的:
version: '3'
services:
(...)
networks:
home:
external:
name: my_other_service_home
iot:
driver: macvlan
driver_opts:
parent: enp1s0.12
ipam:
config:
- subnet: 192.168.12.0/24
為了清楚起見,我更願意在一個單獨的文件中創建所有網絡。 然后在其他撰寫文件中按名稱將它們稱為外部網絡。
但這不起作用:
version: '2'
networks:
iot:
driver: macvlan
driver_opts:
parent: enp1s0.12
ipam:
config:
- subnet: 192.168.12.0/24
management:
driver: macvlan
driver_opts:
parent: enp1s0.10
ipam:
config:
- subnet: 192.168.10.0/24
home:
driver: macvlan
driver_opts:
parent: enp1s0
ipam:
config:
- subnet: 192.168.3.0/24
gateway: 192.168.3.1
該文件被無錯誤地接受,但我剛剛收到網絡未使用的消息,因此未創建。
有更好的方法嗎?
如何在您的networks.yml
文件中創建一個不做任何事情並立即退出的虛擬服務?
這些方面的東西:
# networks.yml
version: '3.7'
services:
dummy:
image: alpine
networks: [hello, sky]
networks:
sky:
name: skynet
hello:
name: hellonet
# service.yml
version: '3.7'
services:
service:
image: alpine
networks: [sky]
networks:
sky:
external:
name: skynet
$ docker-compose -f networks.yml up
$ docker-compose -f service.yml up
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.