0
0

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のLinux OSイメージにあるコマンド一覧を出す

Last updated at Posted at 2019-10-11

動機

Dockerを使ってみようと思っていろいろ調べていると、イメージを作成するには、ベースとなるOSのイメージに対して、いろいろとファイルを追加していく所作をDockerfileに記述するそうなのですが、そこで「べースとなるOSにあらかじめ導入されているコマンドは何か?」という素朴な疑問が湧きます。

原始的な方法でいいではないか

調べたいイメージを走らせてfindでリストする、という原始的な方法を使ってみた。下記は公式のCentos8のパスにあるコマンド一覧を表示させた例。

centos8の実行例
% docker run -it --rm centos:8 /bin/bash -c 'find ${PATH//:/ } -type f -perm /0100 | sort'
/usr/bin/[
/usr/bin/addr2line
/usr/bin/alias
/usr/bin/ar
...(途中略)...
/usr/sbin/weak-modules
/usr/sbin/wipefs
/usr/sbin/zdump
/usr/sbin/zic
/usr/sbin/zramctl

バリエーション

上記実行例では、GNUのfindが入っていることを仮定している。BSD系のfindが入っているOSイメージの場合には、findのオプションを-perm /0100から-perm -0100に変える必要があるのではないかと思う。また、そもそもOSイメージにfindが入っていなかったら使えない方法ではある。

応用

同様の方法で、もともとインストールされているパッケージの一覧も表示させてみた。下記の例はRedHat系Linux想定して、host OSでソート。

応用例
% docker run -it --rm centos:8 rpm -qa | sort
acl-2.2.53-1.el8.x86_64
audit-libs-3.0-0.10.20180831git0047a6c.el8.x86_64
basesystem-11-5.el8.noarch
bash-4.4.19-7.el8.x86_64
bind-export-libs-9.11.4-16.P2.el8.x86_64
...(途中略)...
vim-minimal-8.0.1763-10.el8.x86_64
xz-5.2.4-3.el8.x86_64
xz-libs-5.2.4-3.el8.x86_64
yum-4.0.9.2-5.el8.noarch
zlib-1.2.11-10.el8.x86_64
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?