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

コンテナやPodをポイ捨てするワンライナー ( Docker, Kubernetes )

Last updated at Posted at 2018-11-06

使いどころ:ワンポイントリリーフでコンテナやPodに仕事を任せたい時(そして不要になったら速やかに抹殺したい時)

Dockerコンテナをポイ捨てする

docker run -it --rm --name poisute alpine sh -c "while true; do date; sleep 3; done"

--rmオプションによりCtrl + c でコンテナ終了とともにコンテナは削除されるので不要になったらポイ捨てできる

kubernetesのPodをポイ捨てする

kubectl run -it --rm --restart=Never poisute --image=alpine -- sh -c "while true; do date; sleep 3; done"

--rmオプションによりCtrl + c でPod終了とともにPodは削除されるので不要になったら使い捨てにできる

今回は動作確認用に、shには以下のように3sec毎にdateするコマンドを渡している。
テスト対象Webアプリにwgetするコマンドなどに置き換えるなどすると役立つことがあるかもしれない。
while true; do date; sleep 3; done

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