LoginSignup
3
4

More than 5 years have passed since last update.

基本的なコマンドがDockerイメージにインストールされているかを確認する

Posted at

Dockerfileを書くときに、どのDockerイメージにどのコマンドがインストールされているのか確認してみました。

確認方法

以下のスクリプトを実行。

#!/bin/bash

images=(
  oraclelinux:7.3
  debian:jessie
  buildpack-deps:jessie-scm
  alpine:3.5
  ubuntu:16.04
)

commands=(
  awk
  bash
  curl
  git
  make
  python
  python3
  wget
)

for image in "${images[@]}"; do
  docker pull "$image"
done

for image in "${images[@]}"; do
  echo "### $image ###"
  for com in "${commands[@]}"; do
    echo "echo $com: \$(command -v $com 2>/dev/null || echo 'not found')" | docker run -i --rm "$image" sh
  done
  echo
done

確認結果

### oraclelinux:7.3 ###
awk: /usr/bin/awk
bash: /usr/bin/bash
curl: /usr/bin/curl
git: not found
make: not found
python: /usr/bin/python
python3: not found
wget: not found

### debian:jessie ###
awk: /usr/bin/awk
bash: /bin/bash
curl: not found
git: not found
make: not found
python: not found
python3: not found
wget: not found

### buildpack-deps:jessie-scm ###
awk: /usr/bin/awk
bash: /bin/bash
curl: /usr/bin/curl
git: /usr/bin/git
make: not found
python: /usr/bin/python
python3: not found
wget: /usr/bin/wget

### alpine:3.5 ###
awk: /usr/bin/awk
bash: not found
curl: not found
git: not found
make: not found
python: not found
python3: not found
wget: /usr/bin/wget

### ubuntu:16.04 ###
awk: /usr/bin/awk
bash: /bin/bash
curl: not found
git: not found
make: not found
python: not found
python3: not found
wget: not found
3
4
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
3
4