Translated message

A translation of this page exists in English.

systemd からコンテナーを起動する

更新 -

コンテナーを起動時に自動的に起動するには、/etc/systemd/system/ ディレクトリに unit 設定ファイルを作成し、systemd サービスとして設定します。たとえば、/etc/systemd/system/redis-container.service は以下のようになります。

[Unit]
Description=Redis container
Author=Me
After=docker.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a redis_server
ExecStop=/usr/bin/docker stop -t 2 redis_server

[Install]
WantedBy=local.target

unit ファイルを作成したら、systemctl enable コマンドを実行してコンテナーを自動的に起動します。

systemd を使用してサービスを設定する方法については、Red Hat Enterprise Linux 7 System Administrators GuideManaging Services with systemd 章を参照してください。

Comments