简体   繁体   中英

Docker Compose on Cloud Init Azure

There is a VM scale set running with Centos 7 custom image. Required to run below script as cloud-init script while scaling the VM Scale set. But VM scaled, the script not executed. From the server also not able to locate the execution history. This is the command I used,

#cloud-config
runcmd:
– cd /srv/compose/composeforsvaret/
– docker-compose stop
- docker-compose up -d
final_message: "Your Docker server is now ready."

The commands are not executed, because the syntax is not recognized.
I read in thecloud init documentation about runcmd

the list has to be proper yaml, so you have to quote any characters yaml would eat (':' can be problematic)

This should do the trick:

runcmd:
– [ cd, /srv/compose/composeforsvaret, / ] // or - [ sh, -c , "cd /srv/compose/composeforsvaret" ]
– [ sh, -c, "docker-compose stop" ]
- [ sh, -c, "docker-compose up -d" ]
final_message: "Your Docker server is now ready."

Also keep in mind that runcmd only runs during the first boot, so depending on your purpose you should consider bootcmd !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM