我刚刚开始学习docker的工作原理,在使用docker-compose时遇到了yaml文件的问题。
version: '3.7'
services:
portainer:
container_name: portainer
image: portainer/portainer
volumes:
- portainer_data:/data
- /var/run/docker.sock:/var/run/docker.sock
restart: always
ports:
- "9000:9000"
hass:
container_name: hass
image: homeassistant/home-assistant
volumes:
- /home/flory/home_assistant:/config
- /etc/letsencrypt:/certs
restart: always
network_mode: host
mqtt:
container_name: mqtt
container_name: mqtt
image: eclipse-mosquitto
restart: always
volumes:
- /home/flory/mosquitto/config: /mosquitto/config
- /home/flory/mosquitto/data: /mosquitto/data
- /home/flory/mosquitto/log: /mosquitto/log
ports:
- 1883:1883
- 9000:9000
volumes:
portainer_data:
我收到如下错误:
services.mqtt.volumes“type”是必需属性。
有人可以帮我纠正这个问题吗?
答案1
删除此处多余的空格:
volumes:
- /home/flory/mosquitto/config: /mosquitto/config
- /home/flory/mosquitto/data: /mosquitto/data
- /home/flory/mosquitto/log: /mosquitto/log
看起来是这样的:
volumes:
- /home/flory/mosquitto/config:/mosquitto/config
- /home/flory/mosquitto/data:/mosquitto/data
- /home/flory/mosquitto/log:/mosquitto/log