4
2

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.

DockerHubからDockerfileを確認するスクリプト

4
Posted at

API探したけど探しきらなかった。

要: pandoc

check_dockerfile.sh
set -eu
if [ ! $# -eq 1 ];then
    echo "usage: $0 'docker image name'"
    echo "   ex: $0 tukiyo3/ubuntu-dev"
    exit 1
fi

IMAGE=$1
URL="https://hub.docker.com/r/$IMAGE/~/dockerfile/"

pandoc --no-wrap -f html -t markdown $URL  |
awk '
BEGIN{RS="\n\n"}
/FROM/{print}
' |
sed -e 's/RUN/\nRUN/g' \
    -e 's/ENTRYPOINT/\nENTRYPOINT/g' \
    -e 's/VOLUME/\nVOLUME/g' \
    -e 's/ENV/\nENV/g' \
    -e 's/EXPOSE/\nEXPOSE/g' \
    -e 's/CMD/\nCMD/g' \
    -e 's/\\\\/\n/g' \
    -e 's/\\//g' \
    -e 's/#/\n#/g'
echo
echo open $URL
  • 変換しやすいように、htmlをmarkdownに変換、行の折り返しを無効(pandoc)
  • FROMから始まり、"\n\n"までの複数行を取得(awk)
  • 改行コードが消えているので挿入(sed)

使い方

sh check_dockerfile.sh tukiyo3/ubuntu-dev

おかしい箇所あるが欲しい情報は取れる。
さらに確認したい場合は出力されるURLをブラウザで確認。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?