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

調査用コマンドが不足しているDockerコンテナに手軽に必要コマンドを導入する

Last updated at Posted at 2019-09-22

コンテナ内の調査時に必要コマンドがインストールされていない場合、都度個別にコマンドインストールするのは骨が折れます。その場合は、BusyBoxを使うと便利だそうです。

こちらの記事に書いてある内容を抜粋して以下に記載しています。
https://kazuhira-r.hatenablog.com/entry/2019/04/28/022717

BusyBoxとは?

BusyBoxとは、Aboutページによると「多くの一般的なUnixユーティリティを小さな実行可能ファイルにまとめたもの」

Dockerイメージで提供されていたり、Alpine Linuxに利用されていたりするみたい。

BusyBoxのコマンドを調査対象コンテナに導入する

BusyBoxの個別コマンドをそれぞれ入れることも可能みたいですが、
全コマンドを入れるやり方だけを共有。個別で入れる場合は、個別コマンドのみをダウンロード。

ダウンロードしたモジュールを調査用コンテナのパスが通ったディレクトリにコピーすれば、コンテナ内でコマンド実行が可能となります。

$ wget https://busybox.net/downloads/binaries/1.30.0-i686/busybox
$ chmod a+x busybox
$ docker container cp busybox [コンテナ名]:/usr/local/bin

BusyBoxのコマンドの使い方

あとは、使えるコマンドを確認して、使うだけ。

# busyboxで使えるコマンド一覧を表示
$ busybox

# psを使う場合は、busyboxのサブコマンドとして実行
$ busybox ps
PID   USER     TIME  COMMAND
    1 root      0:00 bash
   58 root      0:00 busybox ps
0
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
0
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?