Prepare init script
To keep cloud-config.yml simple call init.sh only.
$ cd /path/to/docker-compose/project
$ vim init.sh
#!/bin/bash -ex
cd $(dirname $0)
/opt/bin/docker-compose $1
$ chmod +x init.sh
Register init script to cloud-config
$ sudo vim /usr/share/oem/cloud-config.yml
#cloud-config
coreos:
units:
- name: docker-xxx.service
command: start
content: |
[Unit]
Description=Xxx container
After=docker.service
[Service]
Restart=always
ExecStart=/path/to/docker-compose/project/init.sh start
ExecStop=/path/to/docker-compose/project/init.sh stop