0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Auto start docker container w/ docker-compose in CoreOS

Posted at

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
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?