vish
vish

Reputation: 791

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."

Upvotes: 0

Views: 394

Answers (1)

Casper Dijkstra
Casper Dijkstra

Reputation: 1895

The commands are not executed, because the syntax is not recognized.
I read in the cloud 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!

Upvotes: 2

Related Questions