LoginSignup
1
2

More than 3 years have passed since last update.

[メモ]Docker コンテナで定期的に任意のコマンドを実行する

Posted at

例えば以下のように書けば date コマンドを10秒ごとに実行する

$docker run -d alpine /bin/sh -c "while :; do sleep 10; date; done"
a7758deaa636b2910696d940d1c30281e3e5ddb4e973c7a8749081ba724940cf

$docker logs a7758deaa636b2910696d940d1c30281e3e5ddb4e973c7a8749081ba724940cf
Sat Nov  9 20:07:39 UTC 2019

while do done で無限ループさせている

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