Saya ingin mengelola layanan Swarm saya menggunakan format Docker Compose YAML
perintah buruh pelabuhan:
docker service create --name node-exporter \
--mode global \
--network proxy \
--mount "type=bind,source=/proc,target=/host/proc" \
--mount "type=bind,source=/sys,target=/host/sys" \
--mount "type=bind,source=/,target=/rootfs" \
--mount "type=bind,source=/etc/hostname,target=/etc/host_hostname" \
-e HOST_HOSTNAME=/etc/host_hostname \
basi/node-exporter:v0.1.1 \
-collector.procfs /host/proc \
-collector.sysfs /host/proc \
-collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)" \
-collector.textfile.directory /etc/node-exporter/ \
-collectors.enabled="conntrack,diskstats,entropy,filefd,filesystem,loadavg,m\
dadm,meminfo,netdev,netstat,stat,textfile,time,vmstat,ipvs"
compose.yml:
version: "3"
services:
node-exporter:
image: basi/node-exporter:v0.1.1
networks:
- mm
volumes:
- /proc:/host/proc
- /sys:/host/sys
- /:/rootfs
- /etc/hostname:/etc/host_hostname
environment:
- HOST_HOSTNAME=/etc/host_hostname
command: [ -collector.procfs,/host/proc,-collector.sysfs=/host/proc,-collector.filesystem.ignored-mount-points,"^/(sys|proc|dev|host|etc)($|/)",-collector.textfile.directory,/etc/node-exporter/,-collectors.enabled="conntrack,diskstats,entropy,filefd,filesystem,loadavg,mdadm,meminfo,netdev,netstat,stat,textfile,time,vmstat,ipvs"]
deploy:
mode: global
Tetapi mendapat kesalahan: Invalid interpolation format for "command" option in service "node-exporter": "^/(sys|proc|dev|host|etc)($|/)"
Tampaknya simbol $
disebabkan. Format apa yang harus saya tulis?
Anda dapat melepaskan simbol $
dengan $
. Lihat dokumen substitusi variabel untuk info lebih lanjut.
Terima kasih!
Menghabiskan lebih dari satu jam untuk menemukan jawaban ini. Terima kasih.
Anda dapat menggunakan $$ (tanda dolar ganda) jika konfigurasi Anda memerlukan tanda dolar literal. Ini juga mencegah Compose menginterpolasi nilai, jadi $$ memungkinkan Anda merujuk ke variabel lingkungan yang tidak ingin diproses oleh Compose.
web:
build: .
command: "$$VAR_NOT_INTERPOLATED_BY_COMPOSE"
Komentar yang paling membantu
Anda dapat melepaskan simbol
$
dengan$
. Lihat dokumen substitusi variabel untuk info lebih lanjut.