117
99

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.

docker-composeでOS起動時にコンテナを自動起動する方法

Last updated at Posted at 2017-05-24

docker単体でOSの起動時にコンテナを起動させる際には
docker run --restart=always redis
といった風に--restart=alwaysとオプションを追加します。
公式ドキュメント
公式ドキュメントの日本語翻訳版(少しバージョンが古いかも)
けど、docker-composeを使う場合はどうすればいいのかわからなくて少し調べたので書きます。

といってもdocker-compose.ymlに1行追加するだけだった

docker-compose.yml
# jenkins
jenkins:
  image: jenkins
  ports:
    - "8080:8080"
  volumes:
    - /root/docker/jenkins/jenkins_home:/var/jenkins_home
  # ここを追加
  restart: always
# ui_for_docker
ui-for-docker:
  image: uifd/ui-for-docker
  ports:
    - "9001:9000"
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  # ここを追加
  restart: always
117
99
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
117
99

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?