84
85

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.

再起動後もコンテナを自動起動する

Last updated at Posted at 2014-07-22

参考: AWS+CoreOS+Dockerでコンテナの自動起動 1 - Qiita

coreosにて確認。

このやり方だとなんでも出来ますね。

/etc/systemd/system/docker1.serviceファイルを作成

/etc/systemd/system/docker1.service
[Unit]
Description=docker1
After=docker.service
Requires=docker.service

[Service]
ExecStart=/usr/bin/docker start dbde0d684c85

[Install]
WantedBy=multi-user.target
$ sudo systemctl enable docker1
ln -s '/etc/systemd/system/docker1.service' '/etc/systemd/system/multi-user.target.wants/docker1.service'
一覧確認
ls -l /etc/systemd/system/multi-user.target.wants/docker*

再起動後も自動起動することを確認。

コンテナ間でlinkしている場合

例: nginxコンテナ が rails にリンクしている場合、
railsから先に立ち上げないとnginxコンテナの起動ができない。

ダメな例
ExecStart=/usr/bin/docker start nginxのCID railsのCID
良い例
ExecStart=/usr/bin/docker start railsのCID nginxのCID
84
85
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
84
85

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?