- 投稿日:2020-07-20T22:36:10+09:00
Docker でps aux などが実行できない場合
対処法
以下を実行する。
yum install procps以下のコマンドが使用できるようになる。
free, kill, pgrep, pkill, pmap, ps, pwdx, skill, slabtop, snice, sysctl, tload, top, uptime, vmstat, w, watchhttp://archive.linux.or.jp/JF/JFdocs/LFS-BOOK/chapter06/procps.html
- 投稿日:2020-07-20T20:26:22+09:00
Windows10 Home にDocker をインストールする方法
Windows10 HomeにDockerを使用
Windows10 Proを買えば、Docker Desktop for Windowsをインストールするだけで済むことを。。。
- PC購入時に予算節約するため、
- Windows10 Home と Proの違いが分からないので、"ま、Homeで良いよ"
と思って、
Windows10 Homeを使用してDocker Desktop for Windowsインストールできず、困っている方、
Windows10 HomeにDockerインストールで無駄な時間を費やしている方
のために、身をもって経験したWindows10 HomeにDockerをインストールする方法をまとめましたので、共有します。環境の整理
PCスペック:
- Windowsのエディション:Windows10 Home
- バージョン:2004 (初期状態1909でしたが、Windowsアップデートしたことで、2004となりました。)
- システムの種類:64ビットオペレーティングシステム、x64ベースプロセッサ
手順
VirtualBox をダウンロードする。
VirtualBoxインストール
「Windows hosts」をクリック、VirtualBox-6.1.12-139181-Win.exeをダウンロードDockerToolbox をダウンロードする。
DockerToolboxインストール
「DockerToolbox-19.03.1.exe」をクリック、DockerToolbox-19.03.1.exeをダウンロードVirtualBoxからインストールする。
*DockerToolboxからインストールすると、DockerToolboxインストールファイルがPCにVirtualBoxがないことを自動検出し、強制チェック入った状態(=外すことができない状態)でDockerToolboxインストールファイルからVirtualBoxをインストールさせてしまう様となる。これじゃ、うまく動作しなかった。VirtualBoxから先にインストールする手順を踏もう。)
DockerToolbox をインストールする。
Docker Quickstart Terminalをダブルクリックする。
*ここでError creating machine...E_FAIL(0x80004005)エラーとなる。落着きPCを再起動する。Docker Quickstart Terminalを再度ダブルクリックする。
*ここでWaiting for an IP...で起動できそうだが、30分、1時間、半日過ぎても進展なかった。
*解決方法はPCの「Windowsの機能」を起動し「仮想マシンプラットフォーム」にチェックが入っていた。これを外す。PCを再起動する。Docker Quickstart Terminalを再度ダブルクリックする。
クジラが現れた!!!成功。
念のため、
docker version
コマンドを打ち込んでdockerコマンドが効くか確認しましょう。
- 投稿日:2020-07-20T18:50:55+09:00
"TERN"を使ってコンテナ内の利用ソフトウェアパッケージを調査
はじめに; TERNとは?
本記事ではTernの利用方法と結果を紹介する.Ternは公式で"Tern is a software package inspection tool for containers. It's written in Python3 with a smattering of shell scripts." と説明されているされているコンテナ内のソフトウェアパッケージを分析するツールである。Scancode-toolkitを呼び出し検出されたパッケージのOSSライセンスの確認を行ったり,cve-bin-toolを呼び出し検出されたパッケージ脆弱性情報の確認を行うことも可能である.
TERN のインストール
インストールにはコードからインストールする他にpipを利用インストール,Vagrantを利用インストールが可能である.TERN の最新版は2020年7月の時点で2.1.1であり,本記事ではこのバージョンのTERNの表示や結果を紹介する.
事前準備
今回はUbuntu18.04,Python3.6を利用,詳細は展開で確認可能
Dockerインストール方法
Dockerインストール$ sudo apt install -y apt-transport-https ca-certificates curl software-properties-common $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" $ sudo apt-get update $ sudo apt-get install docker-ce # Option $ sudo groupadd docker $ sudo adduser $(whoami) docker $ sudo chmod 666 /var/run/docker.sock $ docker images # 確認Dockerのインストール詳細については以下を参照
https://docs.docker.com/engine/install/ubuntu/
Proxy設定方法
proxy設定例$ sudo mkdir -p /etc/systemd/system/docker.service.d $ echo -e "[Service]\nEnvironment=\"HTTP_PROXY=http://your.proxy.url:port/\"" | sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf [Service] Environment="HTTP_PROXY=http://your.proxy.url:port/" "HTTPS_PROXY=https://your.proxy.url:port/" $ sudo systemctl daemon-reload $ sudo systemctl restart docker $ sudo usermod -aG docker $USER
仮想環境構築
環境構築$ sudo apt update -y $ sudo apt install -y attr $ sudo apt install -y git $ sudo apt install -y python3.6 $ sudo apt install -y python3-venv $ python3 -m venv ternenv #Create a python3 virtual environment $ cd ternenv $ source bin/activate #start virtual environment $ deactivate # end environment仮想環境例hama@docker-license:~/TERN/ternenv-new$ ls bin include lib lib64 pyvenv.cfg share tern hama@docker-license:~/TERN/ternenv-new$ source bin/activate (ternenv-new) hama@docker-license:~/TERN/ternenv-new$ deactivate hama@docker-license:~/TERN/ternenv-new$pip 利用インストール
作成した仮想環境で以下を実行
$ pip3 install tern
- Pypi(TERN) から取得
Tern のインストール画面
hama@docker-license:~/TERN/ternenv$ source bin/activate (ternenv) hama@docker-license:~/TERN/ternenv$ pip install tern Collecting tern Downloading https://files.pythonhosted.org/packages/86/46/a45a339ee97c6756e036c222cd0bd416c9088445656a3b96d04676ac536e/tern-2.1.0-py3-none-any.whl (98kB) 100% |████████████████████████████████| 102kB 2.2MB/s Collecting idna==2.9 (from tern) Downloading https://files.pythonhosted.org/packages/89/e3/afebe61c546d18fb1709a61bee788254b40e736cff7271c7de5de2dc4128/idna-2.9-py2.py3-none-any.whl (58kB) 100% |████████████████████████████████| 61kB 6.1MB/s Collecting dockerfile-parse==0.0.17 (from tern) Downloading https://files.pythonhosted.org/packages/d3/0d/650e77c15ba4975e203d6f26a6ce16cb72d935541f09a0188fa6e62ce621/dockerfile_parse-0.0.17-py2.py3-none-any.whl Collecting stevedore==1.32.0 (from tern) Downloading https://files.pythonhosted.org/packages/e6/49/a35dd566626892d577e426dbe5ea424dd7fbe10645f2c1070dcba474eca9/stevedore-1.32.0-py2.py3-none-any.whl (43kB) 100% |████████████████████████████████| 51kB 9.0MB/s Collecting certifi==2020.4.5.1 (from tern) Downloading https://files.pythonhosted.org/packages/57/2b/26e37a4b034800c960a00c4e1b3d9ca5d7014e983e6e729e33ea2f36426c/certifi-2020.4.5.1-py2.py3-none-any.whl (157kB) 100% |████████████████████████████████| 163kB 2.3MB/s Collecting docker==4.2.0 (from tern) Downloading https://files.pythonhosted.org/packages/58/74/379a9d30b1620def158c40b88c43e01c1936a287ebb97afab0699c601c57/docker-4.2.0-py2.py3-none-any.whl (143kB) 100% |████████████████████████████████| 153kB 5.2MB/s Collecting pyyaml==5.3.1 (from tern) Downloading https://files.pythonhosted.org/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz (269kB) 100% |████████████████████████████████| 276kB 1.6MB/s Collecting websocket-client==0.57.0 (from tern) Downloading https://files.pythonhosted.org/packages/4c/5f/f61b420143ed1c8dc69f9eaec5ff1ac36109d52c80de49d66e0c36c3dfdf/websocket_client-0.57.0-py2.py3-none-any.whl (200kB) 100% |████████████████████████████████| 204kB 1.7MB/s Collecting pbr==5.4.5 (from tern) Downloading https://files.pythonhosted.org/packages/96/ba/aa953a11ec014b23df057ecdbc922fdb40ca8463466b1193f3367d2711a6/pbr-5.4.5-py2.py3-none-any.whl (110kB) 100% |████████████████████████████████| 112kB 2.8MB/s Collecting requests==2.23.0 (from tern) Downloading https://files.pythonhosted.org/packages/1a/70/1935c770cb3be6e3a8b78ced23d7e0f3b187f5cbfab4749523ed65d7c9b1/requests-2.23.0-py2.py3-none-any.whl (58kB) 100% |████████████████████████████████| 61kB 7.7MB/s Collecting six==1.15.0 (from tern) Downloading https://files.pythonhosted.org/packages/ee/ff/48bde5c0f013094d729fe4b0316ba2a24774b3ff1c52d924a8a4cb04078a/six-1.15.0-py2.py3-none-any.whl Collecting urllib3==1.25.9 (from tern) Downloading https://files.pythonhosted.org/packages/e1/e5/df302e8017440f111c11cc41a6b432838672f5a70aa29227bf58149dc72f/urllib3-1.25.9-py2.py3-none-any.whl (126kB) 100% |████████████████████████████████| 133kB 3.0MB/s Collecting attrs==19.3.0 (from tern) Downloading https://files.pythonhosted.org/packages/a2/db/4313ab3be961f7a763066401fb77f7748373b6094076ae2bda2806988af6/attrs-19.3.0-py2.py3-none-any.whl Collecting debut==0.9.4 (from tern) Downloading https://files.pythonhosted.org/packages/fa/73/eb4b0de5e9575c5c3e629d6c83d015afac548ad09dbc5d6b6330918bf9c2/debut-0.9.4-py2.py3-none-any.whl Collecting chardet==3.0.4 (from tern) Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB) 100% |████████████████████████████████| 143kB 2.5MB/s Building wheels for collected packages: pyyaml Running setup.py bdist_wheel for pyyaml ... error Complete output from command /home/hama/TERN/ternenv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-2w8qjj6j/pyyaml/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpspcwa0whpip-wheel- --python-tag cp36: usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: -c --help [cmd1 cmd2 ...] or: -c --help-commands or: -c cmd --help error: invalid command 'bdist_wheel' ---------------------------------------- Failed building wheel for pyyaml Running setup.py clean for pyyaml Failed to build pyyaml Installing collected packages: idna, six, dockerfile-parse, pbr, stevedore, certifi, chardet, urllib3, requests, websocket-client, docker, pyyaml, attrs, debut, tern Running setup.py install for pyyaml ... done Successfully installed attrs-19.3.0 certifi-2020.4.5.1 chardet-3.0.4 debut-0.9.4 docker-4.2.0 dockerfile-parse-0.0.17 idna-2.9 pbr-5.4.5 pyyaml-5.3.1 requests-2.23.0 six-1.15.0 stevedore-1.32.0 tern-2.1.0 urllib3-1.25.9 websocket-client-0.57.0 (ternenv) hama@docker-license:~/TERN/ternenv$インストールが成功したら以下のようにバージョンが確認できる
Ternバージョン確認(ternenv) hama@docker-license:~/TERN/ternenv$ tern --version Tern version 2.1.0 python version = 3.6.9 (default, Apr 18 2020, 01:56:04)Tern Dockerイメージのインストール
Dockerでインストール$ docker build -t ternd .
Tern Dockerイメージのインストール画面
Dockerでインストールする場合beach@debian:~/openchaintools/tern$ docker build -t ternd . Sending build context to Docker daemon 10.55MB Step 1/5 : FROM photon:3.0 3.0: Pulling from library/photon 3e2574d05192: Pull complete Digest: sha256:c433475c637adcd81c9434f57decaa417409ef9ebbe174880c7831352ba2353e Status: Downloaded newer image for photon:3.0 ---> a3bbbff46f10 Step 2/5 : RUN tdnf remove -y toybox && tdnf install -y tar findutils attr util-linux python3 python3-pip python3-setuptools git && pip3 install --upgrade pip && pip3 install tern ---> Running in 53ab81e9e805 Refreshing metadata for: 'VMware Photon Linux 3.0 (x86_64) Updates' Refreshing metadata for: 'VMware Photon Extras 3.0 (x86_64)' Refreshing metadata for: 'VMware Photon Linux 3.0 (x86_64)' Installing: gmp x86_64 6.1.2-3.ph3 photon-updates 524.08k 536656 grep x86_64 3.1-2.ph3 photon-updates 241.50k 247301 coreutils x86_64 8.30-2.ph3 photon-updates 5.84M 6127774 Total installed size: 6.59M 6911731 Removing: toybox x86_64 0.8.2-1.ph3 @System 343.17k 351410 Total installed size: 343.17k 351410 Downloading: Testing transaction Running transaction Installing/Updating: gmp-6.1.2-3.ph3.x86_64 Installing/Updating: coreutils-8.30-2.ph3.x86_64 Installing/Updating: grep-3.1-2.ph3.x86_64 Removing: toybox-0.8.2-1.ph3.x86_64 Complete! Installing: libgcrypt x86_64 1.8.5-1.ph3 photon-updates 1.18M 1232716 pcre-libs x86_64 8.42-1.ph3 photon 278.01k 284680 glib x86_64 2.58.0-4.ph3 photon-updates 3.11M 3265152 openldap x86_64 2.4.48-2.ph3 photon-updates 1.59M 1666001 libgpg-error x86_64 1.32-1.ph3 photon 203.31k 208186 kmod x86_64 25-1.ph3 photon 247.49k 253427 elfutils x86_64 0.176-1.ph3 photon-updates 1.74M 1821041 systemd x86_64 239-24.ph3 photon-updates 20.19M 21173459 cracklib x86_64 2.9.6-8.ph3 photon 43.37k 44408 Linux-PAM x86_64 1.3.0-1.ph3 photon 1.06M 1113660 cyrus-sasl x86_64 2.1.26-16.ph3 photon-updates 637.70k 653008 serf x86_64 1.3.9-1.ph3 photon 110.17k 112816 subversion x86_64 1.10.2-5.ph3 photon-updates 7.75M 8128609 apr x86_64 1.6.5-2.ph3 photon-updates 619.72k 634595 libstdc++ x86_64 7.3.0-4.ph3 photon 1.62M 1694772 nss x86_64 3.44-4.ph3 photon-updates 2.19M 2298787 utf8proc x86_64 2.2.0-1.ph3 photon 321.91k 329632 apr-util x86_64 1.6.1-2.ph3 photon 267.83k 274263 subversion-perl x86_64 1.10.2-5.ph3 photon-updates 4.90M 5138434 pkg-config x86_64 0.29.2-2.ph3 photon 610.51k 625164 python2-libs x86_64 2.7.17-4.ph3 photon-updates 15.55M 16309966 python2 x86_64 2.7.17-4.ph3 photon-updates 1.83M 1913661 gdbm x86_64 1.18-1.ph3 photon 256.88k 263044 perl x86_64 5.28.0-7.ph3 photon-updates 56.89M 59655796 ncurses x86_64 6.1-2.ph3 photon-updates 357.89k 366475 libffi x86_64 3.2.1-6.ph3 photon 39.28k 40224 perl-DBI x86_64 1.641-1.ph3 photon 1.81M 1898474 perl-YAML noarch 1.26-1.ph3 photon 132.69k 135872 perl-CGI noarch 4.40-1.ph3 photon 538.61k 551538 python3-xml x86_64 3.7.5-3.ph3 photon-updates 333.69k 341698 xz x86_64 5.2.4-1.ph3 photon 166.45k 170445 python3-libs x86_64 3.7.5-3.ph3 photon-updates 22.88M 23992074 util-linux-libs x86_64 2.32.1-2.ph3 photon-updates 723.08k 740432 git x86_64 2.23.3-1.ph3 photon-updates 24.89M 26100865 python3-setuptools noarch 3.7.5-3.ph3 photon-updates 1.61M 1692186 python3-pip noarch 3.7.5-3.ph3 photon-updates 4.28M 4489641 python3 x86_64 3.7.5-3.ph3 photon-updates 2.90M 3044206 util-linux x86_64 2.32.1-2.ph3 photon-updates 5.27M 5528420 attr x86_64 2.4.48-1.ph3 photon 87.45k 89546 findutils x86_64 4.6.0-5.ph3 photon 518.63k 531082 tar x86_64 1.30-4.ph3 photon-updates 4.65M 4880464 Total installed size: 194.25M 203688919 Downloading: Testing transaction Running transaction Installing/Updating: util-linux-libs-2.32.1-2.ph3.x86_64 Installing/Updating: apr-1.6.5-2.ph3.x86_64 Installing/Updating: xz-5.2.4-1.ph3.x86_64 Installing/Updating: libffi-3.2.1-6.ph3.x86_64 Installing/Updating: ncurses-6.1-2.ph3.x86_64 Installing/Updating: gdbm-1.18-1.ph3.x86_64 Installing/Updating: perl-5.28.0-7.ph3.x86_64 Installing/Updating: pkg-config-0.29.2-2.ph3.x86_64 Installing/Updating: python2-libs-2.7.17-4.ph3.x86_64 Installing/Updating: python2-2.7.17-4.ph3.x86_64 Installing/Updating: python3-3.7.5-3.ph3.x86_64 Installing/Updating: python3-libs-3.7.5-3.ph3.x86_64 Installing/Updating: utf8proc-2.2.0-1.ph3.x86_64 Installing/Updating: libstdc++-7.3.0-4.ph3.x86_64 Installing/Updating: libgpg-error-1.32-1.ph3.x86_64 Installing/Updating: libgcrypt-1.8.5-1.ph3.x86_64 Installing/Updating: elfutils-0.176-1.ph3.x86_64 Installing/Updating: nss-3.44-4.ph3.x86_64 Installing/Updating: apr-util-1.6.1-2.ph3.x86_64 Installing/Updating: python3-xml-3.7.5-3.ph3.x86_64 Installing/Updating: perl-DBI-1.641-1.ph3.x86_64 Installing/Updating: perl-YAML-1.26-1.ph3.noarch Installing/Updating: perl-CGI-4.40-1.ph3.noarch Installing/Updating: kmod-25-1.ph3.x86_64 Installing/Updating: cracklib-2.9.6-8.ph3.x86_64 using empty dict to provide pw_dict Installing/Updating: Linux-PAM-1.3.0-1.ph3.x86_64 Installing/Updating: pcre-libs-8.42-1.ph3.x86_64 Installing/Updating: glib-2.58.0-4.ph3.x86_64 Installing/Updating: systemd-239-24.ph3.x86_64 Installing/Updating: cyrus-sasl-2.1.26-16.ph3.x86_64 Installing/Updating: openldap-2.4.48-2.ph3.x86_64 Installing/Updating: serf-1.3.9-1.ph3.x86_64 Installing/Updating: subversion-1.10.2-5.ph3.x86_64 Installing/Updating: subversion-perl-1.10.2-5.ph3.x86_64 Installing/Updating: git-2.23.3-1.ph3.x86_64 Installing/Updating: python3-pip-3.7.5-3.ph3.noarch Installing/Updating: python3-setuptools-3.7.5-3.ph3.noarch Installing/Updating: util-linux-2.32.1-2.ph3.x86_64 Installing/Updating: tar-1.30-4.ph3.x86_64 Installing/Updating: findutils-4.6.0-5.ph3.x86_64 Installing/Updating: attr-2.4.48-1.ph3.x86_64 Complete! Collecting pip Downloading https://files.pythonhosted.org/packages/43/84/23ed6a1796480a6f1a2d38f2802901d078266bda38388954d01d3f2e821d/pip-20.1.1-py2.py3-none-any.whl (1.5MB) Installing collected packages: pip Found existing installation: pip 19.2.3 Uninstalling pip-19.2.3: Successfully uninstalled pip-19.2.3 Successfully installed pip-20.1.1 Collecting tern Downloading tern-2.1.0-py3-none-any.whl (98 kB) Collecting urllib3==1.25.9 Downloading urllib3-1.25.9-py2.py3-none-any.whl (126 kB) Collecting dockerfile-parse==0.0.17 Downloading dockerfile_parse-0.0.17-py2.py3-none-any.whl (13 kB) Collecting idna==2.9 Downloading idna-2.9-py2.py3-none-any.whl (58 kB) Collecting requests==2.23.0 Downloading requests-2.23.0-py2.py3-none-any.whl (58 kB) Collecting stevedore==1.32.0 Downloading stevedore-1.32.0-py2.py3-none-any.whl (43 kB) Collecting pbr==5.4.5 Downloading pbr-5.4.5-py2.py3-none-any.whl (110 kB) Collecting debut==0.9.4 Downloading debut-0.9.4-py2.py3-none-any.whl (38 kB) Collecting websocket-client==0.57.0 Downloading websocket_client-0.57.0-py2.py3-none-any.whl (200 kB) Collecting pyyaml==5.3.1 Downloading PyYAML-5.3.1.tar.gz (269 kB) Collecting chardet==3.0.4 Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB) Collecting certifi==2020.4.5.1 Downloading certifi-2020.4.5.1-py2.py3-none-any.whl (157 kB) Collecting six==1.15.0 Downloading six-1.15.0-py2.py3-none-any.whl (10 kB) Collecting attrs==19.3.0 Downloading attrs-19.3.0-py2.py3-none-any.whl (39 kB) Collecting docker==4.2.0 Downloading docker-4.2.0-py2.py3-none-any.whl (143 kB) Using legacy setup.py install for pyyaml, since package 'wheel' is not installed. Installing collected packages: urllib3, six, dockerfile-parse, idna, certifi, chardet, requests, pbr, stevedore, attrs, debut, websocket-client, pyyaml, docker, tern Running setup.py install for pyyaml: started Running setup.py install for pyyaml: finished with status 'done' Successfully installed attrs-19.3.0 certifi-2020.4.5.1 chardet-3.0.4 debut-0.9.4 docker-4.2.0 dockerfile-parse-0.0.17 idna-2.9 pbr-5.4.5 pyyaml-5.3.1 requests-2.23.0 six-1.15.0 stevedore-1.32.0 tern-2.1.0 urllib3-1.25.9 websocket-client-0.57.0 Removing intermediate container 53ab81e9e805 ---> 6a1de035c682 Step 3/5 : RUN mkdir hostmount ---> Running in 7bd909d217aa Removing intermediate container 7bd909d217aa ---> e2db6c57008b Step 4/5 : ENTRYPOINT ["tern", "-q", "-b", "/hostmount"] ---> Running in fba412956e94 Removing intermediate container fba412956e94 ---> ecaceed787bd Step 5/5 : CMD ["-h"] ---> Running in 8de2ddd7e3f1 Removing intermediate container 8de2ddd7e3f1 ---> 1bca18e30cc4 Successfully built 1bca18e30cc4 Successfully tagged ternd:latestコードからビルド
最新のTernを利用したいときは以下を実行しインストールする.本記事でも基本的にこの方法でインストールしたものを用いて話を進める.
$ python3 -m venv ternenv-new1 $ cd ternenv-new1/ $ source bin/activate $ git clone https://github.com/tern-tools/tern.git $ cd tern $ pip3 install -r requirements.txt # Dockerの読み込みに時間がかかる環境下では以下のファイルのL.38 timeoutを変更 $ vim tern/analyze/docker/container.py $ python3 setup.py install(注)タイムアウトについては以下参照
https://www.gitmemory.com/issue/vmware/tern/630/611237133上記インストールに問題がなければ,以下のように最新のバージョンがインストールされていることが確認できる.
TERN_version2.1.1確認$ tern --version Tern version 2.1.1 python version = 3.6.9 (default, Apr 18 2020, 01:56:04)TERN の利用方法
はじめに記載した通り,ternはscancode, cve-bin-toolを拡張機能として利用することもでき,これによりOSSライセンスや脆弱性の確認が可能である.ここでは,TERN単独で利用する方法の他にScancodeとcve-bin-toolを利用する方法を紹介する.
TERN 分析と結果出力
まず,TERNだけでコンテナイメージの中のパッケージを調査する方法を紹介する.
基本的には以下のようにternコマンドに必要なオプションを組み合わせて利用する.
Tern実行$ tern report -o output.txt -i debian:buster[-o] で出力ファイル名を指定し,[-i]で調査を行うイメージの指定をする.なおDocker imageは以下で確認でき,[-i]オプションには[REPOSITORY]:[TAG]の形式で記載する必要がある.
Dockerイメージの参照$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE golang 1.14.4 00d970a31ef2 3 weeks ago 810MB golang latest 00d970a31ef2 3 weeks ago 810MB ubuntu latest 74435f89ab78 4 weeks ago 73.9MB debian buster 1b686a95ddbf 5 weeks ago 114MB fossology/fossology 3.8.1 164d5611fa8d 8 weeks ago 644MB
オプションは他にアウトプット表示をなくす[-q]やデバック用にワーキングディレクトリを残す[-k] がある.v2.1.1ではv2.1.0ではバグできなかった[-w]又は[--raw-image]でローカルに保存している raw container image のtarファイルを対象を指定することも可能となっている.
詳細は以下を参考にしてほしい.
Ternオプション
ternオプション$ tern --help usage: Tern [-h] [-q] [-c] [-k] [-b BIND_DIR] [-r] [-wd PATH] [-v] {report,lock} ... Tern is a container image component curation tool. Tern retrieves information about packages that are installed in a container image. Learn more at https://github.com/tern-tools/tern positional arguments: {report,lock} Subcommands report Create a BoM report. Run 'tern report -h' for report for mat options. lock Create an annotated Dockerfile that will pin the informa tion it finds. Use this option to help achieve a more repeatable container image build. optional arguments: -h, --help show this help message and exit -q, --quiet Silences the output to the terminal;Useful when logging behaviour unnecessary -c, --clear-cache Clear the cache before running -k, --keep-wd Keep the working directory after execution. Useful when debugging container images -b BIND_DIR, --bind-mount BIND_DIR Absolute path to bind mount target. Needed when running from within a container. -r, --redo Repopulate the cache for found layers -wd PATH, --working-dir PATH Change default working directory to specifiedabsolute path. -v, --version show program's version number and exit実際にdebian:busterのイメージを分析すると,ターミナル上には以下のように表⽰される.
Tern実行画面
$ tern report -o output.txt -i debian:buster 2020-06-19 16:30:37,688 - DEBUG - __main__ - Starting... 2020-06-19 16:30:37,688 - DEBUG - run - Setting up... 2020-06-19 16:30:37,692 - DEBUG - container - Checking if image "debian:buster" is available on disk... 2020-06-19 16:30:37,694 - DEBUG - container - Attempting to pull image "debian:buster" 2020-06-19 16:31:03,144 - DEBUG - container - Image "debian:buster" downloaded 2020-06-19 16:31:03,145 - DEBUG - container - Checking if image "debian:buster" is available on disk... 2020-06-19 16:31:03,147 - DEBUG - container - Image "debian:buster" found 2020-06-19 16:31:05,908 - DEBUG - rootfs - Running command: tar -tf /home/hama/.tern/temp.tar 2020-06-19 16:31:05,911 - DEBUG - rootfs - Running command: tar -x --exclude=.wh.* -f /home/hama/.tern/temp.tar -C /home/hama/.tern/temp 2020-06-19 16:31:06,080 - DEBUG - rootfs - Running command: tar -tf /home/hama/.tern/temp/f7e7c23401d7e2b69d969f9a1d6daa273774cc3a0e871c08770721ff7f30b58a/layer.tar 2020-06-19 16:31:06,106 - DEBUG - rootfs - Running command: tar -x --exclude=.wh.* -f /home/hama/.tern/temp/f7e7c23401d7e2b69d969f9a1d6daa273774cc3a0e871c08770721ff7f30b58a/layer.tar -C /home/hama/.tern/temp/f7e7c23401d7e2b69d969f9a1d6daa273774cc3a0e871c08770721ff7f30b58a/contents 2020-06-19 16:31:06,467 - DEBUG - rootfs - Running command: sudo /home/hama/TERN/ternenv/lib/python3.6/site-packages/tern/tools/fs_hash.sh /home/hama/.tern/temp/f7e7c23401d7e2b69d969f9a1d6daa273774cc3a0e871c08770721ff7f30b58a/contents 2020-06-19 16:31:16,451 - DEBUG - common - Reading files in filesystem... 2020-06-19 16:31:19,372 - DEBUG - rootfs - Running command: sudo mount -o bind /home/hama/.tern/temp/f7e7c23401d7e2b69d969f9a1d6daa273774cc3a0e871c08770721ff7f30b58a/contents /home/hama/.tern/temp/mergedir 2020-06-19 16:31:19,387 - DEBUG - rootfs - Running command: sudo mount -t proc /proc /home/hama/.tern/temp/mergedir/proc 2020-06-19 16:31:19,396 - DEBUG - rootfs - Running command: sudo mount -o bind /sys /home/hama/.tern/temp/mergedir/sys 2020-06-19 16:31:19,407 - DEBUG - rootfs - Running command: sudo mount -o bind /dev /home/hama/.tern/temp/mergedir/dev 2020-06-19 16:31:19,419 - DEBUG - rootfs - Running command: sudo cp /etc/resolv.conf /home/hama/.tern/temp/mergedir/etc/resolv.conf 2020-06-19 16:31:19,427 - DEBUG - rootfs - Running command: sudo unshare -pf --mount-proc=/home/hama/.tern/temp/mergedir/proc chroot /home/hama/.tern/temp/mergedir /bin/sh -c dpkg --get-selections | cut -f1 -d':' | awk '{print $1}' 2020-06-19 16:31:19,498 - DEBUG - rootfs - Running command: sudo unshare -pf --mount-proc=/home/hama/.tern/temp/mergedir/proc chroot /home/hama/.tern/temp/mergedir /bin/sh -c pkgs=`dpkg --get-selections | cut -f1 -d':' | awk '{print $1}'` && for p in $pkgs; do dpkg -l $p | awk 'NR>5 {print $3}'; done 2020-06-19 16:31:19,938 - DEBUG - rootfs - Running command: sudo unshare -pf --mount-proc=/home/hama/.tern/temp/mergedir/proc chroot /home/hama/.tern/temp/mergedir /bin/sh -c pkgs=`dpkg --get-selections | cut -f1 -d':' | awk '{print $1}'` && for p in $pkgs; do /bin/cat /usr/share/doc/$p/copyright; echo LICF; done 2020-06-19 16:31:20,253 - WARNING - common - Inconsistent lengths for key: proj_urls 2020-06-19 16:31:20,263 - DEBUG - rootfs - Running command: sudo umount /home/hama/.tern/temp/mergedir/proc 2020-06-19 16:31:20,334 - DEBUG - rootfs - Running command: sudo umount /home/hama/.tern/temp/mergedir/sys 2020-06-19 16:31:20,366 - DEBUG - rootfs - Running command: sudo umount /home/hama/.tern/temp/mergedir/dev 2020-06-19 16:31:20,402 - DEBUG - rootfs - Running command: sudo umount -rl /home/hama/.tern/temp/mergedir 2020-06-19 16:31:20,780 - DEBUG - generator - Creating a detailed report of components in image... 2020-06-19 16:31:20,784 - DEBUG - rootfs - Running command: sudo rm -rf /home/hama/.tern/temp/f7e7c23401d7e2b69d969f9a1d6daa273774cc3a0e871c08770721ff7f30b58a/contents 2020-06-19 16:31:20,929 - DEBUG - run - Teardown... 2020-06-19 16:31:29,465 - DEBUG - rootfs - Running command: sudo rm -rf /home/hama/.tern/temp/mergedir 2020-06-19 16:31:29,474 - DEBUG - rootfs - Running command: sudo rm -rf /home/hama/.tern/temp/workdir 2020-06-19 16:31:29,503 - DEBUG - __main__ - Report completed. 2020-06-19 16:31:29,503 - DEBUG - __main__ - Finished出力フォーマットはjson, yaml, html,SPDX tag-value 形式選択可能であり,例えば htmlやSPDX tag-value 形式で出力したい場合は,[-f]オプションを利用して以下のようにTERNを実行する.
TERN結果html出力$ tern report -f html -i golang:1.12-alpine -o report.html(注) html 形式を利用するにはここより後にコミットされたTERNを利用する必要があり,2020年7月pipでインストールするVersion2.1では利用できない.
TERN結果SPDX_tag-value出力$ tern report -f spdxtagvalue -i golang:1.12-alpine -o spdx.txtScanCodeを用いたTERNの分析結果出力
OSSライセンスの検出を行うOSSScancodeを呼び出して利用することができる.この機能を利用する場合scancodeのインストールをTERNと同じ環境で行う必要がある.
scancodeのインストール$ pip3 install scancode-toolkit[-x]オプション付けることで利用できる.
scancodeを組み合わせてTERNの利用$ tern report -x scancode -i golang:1.12-alpine -o scancode-tern.txtcve-bin-toolを用いたTERNの分析結果出力
脆弱性の調査について行うcve-bin-toolを呼び出して利用することができる.この機能を利用する場合cve-bin-toolのインストールをTERNと同じ環境で行う必要がある.
$ pip3 install cve-bin-tool[-x]オプション付けることで利用できる.
cve-bin-toolを組み合わせてTERNの利用$ tern report -x cve_bin_tool -i golang:1.12-alpine -o cve-bin-tool-out-put.txt
cve-bin-toolを用いたTERNの分析結果出力
cve-bin-toolを用いたTERNの分析結果出力(ternenv) beach@beach:~/TERN/ternenv$ tern report -x cve_bin_tool -i golang:1.12-alpine 2020-07-20 16:51:15,956 - DEBUG - __main__ - Starting... 2020-07-20 16:51:15,957 - DEBUG - run - Setting up... 2020-07-20 16:51:15,962 - DEBUG - container - Checking if image "golang:1.12-alpine" is available on disk... 2020-07-20 16:51:15,966 - DEBUG - container - Attempting to pull image "golang:1.12-alpine" 2020-07-20 16:52:19,885 - DEBUG - container - Image "golang:1.12-alpine" downloaded 2020-07-20 16:52:19,886 - DEBUG - container - Checking if image "golang:1.12-alpine" is available on disk... 2020-07-20 16:52:19,889 - DEBUG - container - Image "golang:1.12-alpine" found 2020-07-20 16:52:26,344 - DEBUG - rootfs - Running command: tar -tf /home/beach/.tern/temp.tar 2020-07-20 16:52:26,355 - DEBUG - rootfs - Running command: tar -x --exclude=.wh.* -f /home/beach/.tern/temp.tar -C /home/beach/.tern/temp 2020-07-20 16:52:27,463 - DEBUG - rootfs - Running command: tar -tf /home/beach/.tern/temp/daa4253bbe5a2459c4aa33b3ccac33c06c4e055d6c1093bb477a371ed4a8eef0/layer.tar 2020-07-20 16:52:27,485 - DEBUG - rootfs - Running command: tar -x --exclude=.wh.* -f /home/beach/.tern/temp/daa4253bbe5a2459c4aa33b3ccac33c06c4e055d6c1093bb477a371ed4a8eef0/layer.tar -C /home/beach/.tern/temp/daa4253bbe5a2459c4aa33b3ccac33c06c4e055d6c1093bb477a371ed4a8eef0/contents 2020-07-20 16:52:27,526 - DEBUG - rootfs - Running command: sudo /home/beach/TERN/ternenv/lib/python3.6/site-packages/tern/tools/fs_hash.sh /home/beach/.tern/temp/daa4253bbe5a2459c4aa33b3ccac33c06c4e055d6c1093bb477a371ed4a8eef0/contents 2020-07-20 16:52:27,724 - DEBUG - rootfs - Running command: tar -tf /home/beach/.tern/temp/a4816229dbc332c74de29ac6a705ba1db243d263fe7dd0088062a4495af8672b/layer.tar 2020-07-20 16:52:27,740 - DEBUG - rootfs - Running command: tar -x --exclude=.wh.* -f /home/beach/.tern/temp/a4816229dbc332c74de29ac6a705ba1db243d263fe7dd0088062a4495af8672b/layer.tar -C /home/beach/.tern/temp/a4816229dbc332c74de29ac6a705ba1db243d263fe7dd0088062a4495af8672b/contents 2020-07-20 16:52:27,771 - DEBUG - rootfs - Running command: sudo /home/beach/TERN/ternenv/lib/python3.6/site-packages/tern/tools/fs_hash.sh /home/beach/.tern/temp/a4816229dbc332c74de29ac6a705ba1db243d263fe7dd0088062a4495af8672b/contents 2020-07-20 16:52:28,096 - DEBUG - rootfs - Running command: tar -tf /home/beach/.tern/temp/17eef46af9e25447ee0fb79ae1b71ca951ba977994ded0c72ada109d3a0f4e93/layer.tar 2020-07-20 16:52:28,101 - DEBUG - rootfs - Running command: tar -x --exclude=.wh.* -f /home/beach/.tern/temp/17eef46af9e25447ee0fb79ae1b71ca951ba977994ded0c72ada109d3a0f4e93/layer.tar -C /home/beach/.tern/temp/17eef46af9e25447ee0fb79ae1b71ca951ba977994ded0c72ada109d3a0f4e93/contents 2020-07-20 16:52:28,106 - DEBUG - rootfs - Running command: sudo /home/beach/TERN/ternenv/lib/python3.6/site-packages/tern/tools/fs_hash.sh /home/beach/.tern/temp/17eef46af9e25447ee0fb79ae1b71ca951ba977994ded0c72ada109d3a0f4e93/contents 2020-07-20 16:52:28,121 - DEBUG - rootfs - Running command: tar -tf /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/layer.tar 2020-07-20 16:52:28,298 - DEBUG - rootfs - Running command: tar -x --exclude=.wh.* -f /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/layer.tar -C /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents 2020-07-20 16:52:29,569 - DEBUG - rootfs - Running command: sudo /home/beach/TERN/ternenv/lib/python3.6/site-packages/tern/tools/fs_hash.sh /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents 2020-07-20 16:52:48,971 - DEBUG - rootfs - Running command: tar -tf /home/beach/.tern/temp/a5eb87b130e3b9e9032b6a544e220c66cba93be2f82927728c1ee27cc15d78d8/layer.tar 2020-07-20 16:52:48,976 - DEBUG - rootfs - Running command: tar -x --exclude=.wh.* -f /home/beach/.tern/temp/a5eb87b130e3b9e9032b6a544e220c66cba93be2f82927728c1ee27cc15d78d8/layer.tar -C /home/beach/.tern/temp/a5eb87b130e3b9e9032b6a544e220c66cba93be2f82927728c1ee27cc15d78d8/contents 2020-07-20 16:52:48,986 - DEBUG - rootfs - Running command: sudo /home/beach/TERN/ternenv/lib/python3.6/site-packages/tern/tools/fs_hash.sh /home/beach/.tern/temp/a5eb87b130e3b9e9032b6a544e220c66cba93be2f82927728c1ee27cc15d78d8/contents 2020-07-20 16:52:49,054 - DEBUG - executor - Analyzing layer 1 2020-07-20 16:52:49,055 - DEBUG - rootfs - Running command: sudo /home/beach/TERN/ternenv/bin/cve-bin-tool -x -u now /home/beach/.tern/temp/daa4253bbe5a2459c4aa33b3ccac33c06c4e055d6c1093bb477a371ed4a8eef0/contents cve_bin_tool.CVEDB - INFO - Updating CVE data. This will take a few minutes. cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2020.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2019.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2018.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2017.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2016.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2015.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2014.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2013.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2012.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2011.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2010.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2009.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2008.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2007.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2006.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2005.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2004.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2003.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2002.json.gz cve_bin_tool.Scanner - INFO - Checkers: binutils, bluez, bzip2, cups, curl, expat, ffmpeg, gnutls, gstreamer, hostapd, icu, kerberos, libcurl, libdb, libgcrypt, libjpeg, libnss, libtiff, lighttpd, ncurses, nessus, nginx, node, openssh, openssl, openswan, png, postgresql, python, rsyslog, sqlite, strongswan, syslogng, systemd, varnish, wireshark, xerces, xml2, zlib cve_bin_tool - INFO - None cve_bin_tool.Scanner - INFO - /home/beach/.tern/temp/daa4253bbe5a2459c4aa33b3ccac33c06c4e055d6c1093bb477a371ed4a8eef0/contents/lib/libcrypto.so.1.1 is openssl 1.1.1d cve_bin_tool.Scanner - INFO - Known CVEs in version 1.1.1d cve_bin_tool.Scanner - INFO - CVE-1999-0428, CVE-2009-0590, CVE-2009-1390, CVE-2009-3765, CVE-2009-3766, CVE-2009-3767, CVE-2019-0190, CVE-2019-1551, CVE-2020-1967 cve_bin_tool.Scanner - INFO - /home/beach/.tern/temp/daa4253bbe5a2459c4aa33b3ccac33c06c4e055d6c1093bb477a371ed4a8eef0/contents/lib/libz.so.1.2.11 is zlib 1.2.11 cve_bin_tool.Scanner - WARNING - binutils was detected with version UNKNOWN in file /home/beach/.tern/temp/daa4253bbe5a2459c4aa33b3ccac33c06c4e055d6c1093bb477a371ed4a8eef0/contents/lib/ld-musl-x86_64.so.1 cve_bin_tool.Scanner - INFO - /home/beach/.tern/temp/daa4253bbe5a2459c4aa33b3ccac33c06c4e055d6c1093bb477a371ed4a8eef0/contents/lib/libssl.so.1.1 is openssl 1.1.1d cve_bin_tool.Scanner - INFO - Known CVEs in version 1.1.1d cve_bin_tool.Scanner - INFO - CVE-1999-0428, CVE-2009-0590, CVE-2009-1390, CVE-2009-3765, CVE-2009-3766, CVE-2009-3767, CVE-2019-0190, CVE-2019-1551, CVE-2020-1967 cve_bin_tool - INFO - cve_bin_tool - INFO - Overall CVE summary: cve_bin_tool - INFO - There are 2 files with known CVEs detected cve_bin_tool - INFO - Known CVEs in ('openssl', '1.1.1d'), ('zlib', '1.2.11'): /home/beach/.tern/temp/daa4253bbe5a2459c4aa33b3ccac33c06c4e055d6c1093bb477a371ed4a8eef0/contents/lib/apk/db/scripts.tar /tmp/cve-bin-tool-iucckmb_/scripts.tar.extracted +=================================================================+ | ___ _ __ ____ ___ ___ _ _ _____ ___ ___ _ | | / __| \ / /| ___] | )[ ]| \ | | [_ _]| _ || _ || | | | | |__ \ \/ / | _]_ = | < | | | |\| | = | | ||_||||_||| |__ | | \___| \__/ |___ ] |___)[___]|_| \_| |_| |___||___||____| | | | +=================================================================+ | CVE Binary Tool Report Generated: 2020-07-20 17:07:09 | +=================================================================+ +=================================================================+ | MODULE NAME | VERSION | CVE NUMBER | SEVERITY | +=================================================================+ | openssl | 1.1.1d | CVE-1999-0428 | HIGH | +--------------------+-----------+--------------------+-----------+ | openssl | 1.1.1d | CVE-2009-0590 | MEDIUM | +--------------------+-----------+--------------------+-----------+ | openssl | 1.1.1d | CVE-2009-1390 | MEDIUM | +--------------------+-----------+--------------------+-----------+ | openssl | 1.1.1d | CVE-2009-3765 | MEDIUM | +--------------------+-----------+--------------------+-----------+ | openssl | 1.1.1d | CVE-2009-3766 | MEDIUM | +--------------------+-----------+--------------------+-----------+ | openssl | 1.1.1d | CVE-2009-3767 | MEDIUM | +--------------------+-----------+--------------------+-----------+ | openssl | 1.1.1d | CVE-2019-0190 | HIGH | +--------------------+-----------+--------------------+-----------+ | openssl | 1.1.1d | CVE-2019-1551 | MEDIUM | +--------------------+-----------+--------------------+-----------+ | openssl | 1.1.1d | CVE-2020-1967 | HIGH | +--------------------+-----------+--------------------+-----------+ 2020-07-20 17:01:09,434 - DEBUG - executor - Analyzing layer 2 2020-07-20 17:01:09,435 - DEBUG - rootfs - Running command: sudo /home/beach/TERN/ternenv/bin/cve-bin-tool -x -u now /home/beach/.tern/temp/a4816229dbc332c74de29ac6a705ba1db243d263fe7dd0088062a4495af8672b/contents cve_bin_tool.CVEDB - WARNING - Deleting cachedir /home/beach/.cache/cve-bin-tool cve_bin_tool.CVEDB - INFO - Updating CVE data. This will take a few minutes. cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2020.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2019.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2018.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2017.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2016.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2015.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2014.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2013.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2012.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2011.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2010.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2009.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2008.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2007.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2006.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2005.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2004.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2003.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2002.json.gz cve_bin_tool.Scanner - INFO - Checkers: binutils, bluez, bzip2, cups, curl, expat, ffmpeg, gnutls, gstreamer, hostapd, icu, kerberos, libcurl, libdb, libgcrypt, libjpeg, libnss, libtiff, lighttpd, ncurses, nessus, nginx, node, openssh, openssl, openswan, png, postgresql, python, rsyslog, sqlite, strongswan, syslogng, systemd, varnish, wireshark, xerces, xml2, zlib cve_bin_tool - INFO - None cve_bin_tool.Scanner - WARNING - binutils was detected with version UNKNOWN in file /home/beach/.tern/temp/a4816229dbc332c74de29ac6a705ba1db243d263fe7dd0088062a4495af8672b/contents/usr/bin/c_rehash cve_bin_tool - INFO - cve_bin_tool - INFO - Overall CVE summary: cve_bin_tool - INFO - There are 0 files with known CVEs detected /home/beach/.tern/temp/a4816229dbc332c74de29ac6a705ba1db243d263fe7dd0088062a4495af8672b/contents/lib/apk/db/scripts.tar /tmp/cve-bin-tool-op3a_20f/scripts.tar.extracted 2020-07-20 17:08:57,838 - DEBUG - executor - Analyzing layer 3 2020-07-20 17:08:57,839 - DEBUG - rootfs - Running command: sudo /home/beach/TERN/ternenv/bin/cve-bin-tool -x -u now /home/beach/.tern/temp/17eef46af9e25447ee0fb79ae1b71ca951ba977994ded0c72ada109d3a0f4e93/contents cve_bin_tool.CVEDB - WARNING - Deleting cachedir /home/beach/.cache/cve-bin-tool cve_bin_tool.CVEDB - INFO - Updating CVE data. This will take a few minutes. cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2020.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2019.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2018.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2017.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2016.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2015.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2014.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2013.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2012.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2011.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2010.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2009.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2008.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2007.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2006.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2005.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2004.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2003.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2002.json.gz cve_bin_tool.Scanner - INFO - Checkers: binutils, bluez, bzip2, cups, curl, expat, ffmpeg, gnutls, gstreamer, hostapd, icu, kerberos, libcurl, libdb, libgcrypt, libjpeg, libnss, libtiff, lighttpd, ncurses, nessus, nginx, node, openssh, openssl, openswan, png, postgresql, python, rsyslog, sqlite, strongswan, syslogng, systemd, varnish, wireshark, xerces, xml2, zlib cve_bin_tool - INFO - None cve_bin_tool - INFO - cve_bin_tool - INFO - Overall CVE summary: cve_bin_tool - INFO - There are 0 files with known CVEs detected 2020-07-20 17:16:15,407 - DEBUG - executor - Analyzing layer 4 2020-07-20 17:16:15,408 - DEBUG - rootfs - Running command: sudo /home/beach/TERN/ternenv/bin/cve-bin-tool -x -u now /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents cve_bin_tool.CVEDB - WARNING - Deleting cachedir /home/beach/.cache/cve-bin-tool cve_bin_tool.CVEDB - INFO - Updating CVE data. This will take a few minutes. cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2020.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2019.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2018.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2017.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2016.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2015.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2014.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2013.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2012.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2011.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2010.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2009.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2008.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2007.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2006.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2005.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2004.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2003.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2002.json.gz cve_bin_tool.Scanner - INFO - Checkers: binutils, bluez, bzip2, cups, curl, expat, ffmpeg, gnutls, gstreamer, hostapd, icu, kerberos, libcurl, libdb, libgcrypt, libjpeg, libnss, libtiff, lighttpd, ncurses, nessus, nginx, node, openssh, openssl, openswan, png, postgresql, python, rsyslog, sqlite, strongswan, syslogng, systemd, varnish, wireshark, xerces, xml2, zlib cve_bin_tool - INFO - None cve_bin_tool.Scanner - WARNING - binutils was detected with version UNKNOWN in file /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/pkg/tool/linux_amd64/nm cve_bin_tool.Scanner - WARNING - binutils was detected with version UNKNOWN in file /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/pkg/tool/linux_amd64/asm cve_bin_tool.Scanner - WARNING - binutils was detected with version UNKNOWN in file /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/pkg/tool/linux_amd64/buildid cve_bin_tool.Scanner - WARNING - binutils was detected with version UNKNOWN in file /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/pkg/tool/linux_amd64/addr2line cve_bin_tool.Scanner - WARNING - binutils was detected with version UNKNOWN in file /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/pkg/tool/linux_amd64/objdump 世界: mismatching "local" filename (ф╕ЦчХМ), continuing with "central" filename version cve_bin_tool.TempDirExtractorContext - WARNING - Failure extracting /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/utf8-winrar.zip 世界: mismatching "local" filename (ф╕ЦчХМ), continuing with "central" filename version cve_bin_tool.TempDirExtractorContext - WARNING - Failure extracting /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/utf8-winzip.zip 世界: mismatching "local" filename (ф╕ЦчХМ), continuing with "central" filename version cve_bin_tool.TempDirExtractorContext - WARNING - Failure extracting /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/utf8-7zip.zip tar: Unexpected EOF in archive tar: rmtlseek not stopped at a record boundary tar: Error is not recoverable: exiting now cve_bin_tool.TempDirExtractorContext - WARNING - Failure extracting /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/writer-big-long.tar tar: Unexpected EOF in archive tar: Error is not recoverable: exiting now cve_bin_tool.TempDirExtractorContext - WARNING - Failure extracting /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/issue11169.tar Traceback (most recent call last): File "/home/beach/TERN/ternenv/bin/cve-bin-tool", line 11, in <module> load_entry_point('cve-bin-tool==1.0', 'console_scripts', 'cve-bin-tool')() File "/home/beach/TERN/ternenv/lib/python3.6/site-packages/cve_bin_tool/cli.py", line 475, in main scanner, ectx, walker, args.extract, filepath File "/home/beach/TERN/ternenv/lib/python3.6/site-packages/cve_bin_tool/cli.py", line 264, in scan_and_or_extract_file scan_and_or_extract_file(scanner, ectx, walker, should_extract, filename) File "/home/beach/TERN/ternenv/lib/python3.6/site-packages/cve_bin_tool/cli.py", line 257, in scan_and_or_extract_file scanner.scan_file(filepath) File "/home/beach/TERN/ternenv/lib/python3.6/site-packages/cve_bin_tool/cli.py", line 140, in scan_file raise InvalidFileError(filename) cve_bin_tool.cli.InvalidFileError: /tmp/cve-bin-tool-tiily948/hdr-only.tar.extracted/sda /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/lib/time/zoneinfo.zip /tmp/cve-bin-tool-tiily948/zoneinfo.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/time-22738.zip /tmp/cve-bin-tool-tiily948/time-22738.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/dd.zip /tmp/cve-bin-tool-tiily948/dd.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/readme.zip /tmp/cve-bin-tool-tiily948/readme.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/symlink.zip /tmp/cve-bin-tool-tiily948/symlink.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/zip64-2.zip /tmp/cve-bin-tool-tiily948/zip64-2.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/utf8-infozip.zip /tmp/cve-bin-tool-tiily948/utf8-infozip.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/unix.zip /tmp/cve-bin-tool-tiily948/unix.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/time-7zip.zip /tmp/cve-bin-tool-tiily948/time-7zip.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/utf8-winrar.zip /tmp/cve-bin-tool-tiily948/utf8-winrar.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/time-go.zip /tmp/cve-bin-tool-tiily948/time-go.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/test-trailing-junk.zip /tmp/cve-bin-tool-tiily948/test-trailing-junk.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/time-winzip.zip /tmp/cve-bin-tool-tiily948/time-winzip.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/go-with-datadesc-sig.zip /tmp/cve-bin-tool-tiily948/go-with-datadesc-sig.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/winxp.zip /tmp/cve-bin-tool-tiily948/winxp.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/time-infozip.zip /tmp/cve-bin-tool-tiily948/time-infozip.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/zip64.zip /tmp/cve-bin-tool-tiily948/zip64.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/utf8-winzip.zip /tmp/cve-bin-tool-tiily948/utf8-winzip.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/time-winrar.zip /tmp/cve-bin-tool-tiily948/time-winrar.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/utf8-osx.zip /tmp/cve-bin-tool-tiily948/utf8-osx.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/utf8-7zip.zip /tmp/cve-bin-tool-tiily948/utf8-7zip.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/crc32-not-streamed.zip /tmp/cve-bin-tool-tiily948/crc32-not-streamed.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/time-win7.zip /tmp/cve-bin-tool-tiily948/time-win7.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/time-osx.zip /tmp/cve-bin-tool-tiily948/time-osx.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/zip/testdata/test.zip /tmp/cve-bin-tool-tiily948/test.zip.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/writer-big-long.tar /tmp/cve-bin-tool-tiily948/writer-big-long.tar.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/pax.tar /tmp/cve-bin-tool-tiily948/pax.tar.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/nil-uid.tar /tmp/cve-bin-tool-tiily948/nil-uid.tar.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/trailing-slash.tar /tmp/cve-bin-tool-tiily948/trailing-slash.tar.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/file-and-dir.tar /tmp/cve-bin-tool-tiily948/file-and-dir.tar.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/v7.tar /tmp/cve-bin-tool-tiily948/v7.tar.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/gnu-multi-hdrs.tar /tmp/cve-bin-tool-tiily948/gnu-multi-hdrs.tar.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/ustar-file-reg.tar /tmp/cve-bin-tool-tiily948/ustar-file-reg.tar.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/ustar-file-devs.tar /tmp/cve-bin-tool-tiily948/ustar-file-devs.tar.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/pax-nul-path.tar /tmp/cve-bin-tool-tiily948/pax-nul-path.tar.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/issue11169.tar /tmp/cve-bin-tool-tiily948/issue11169.tar.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/gnu-nil-sparse-hole.tar /tmp/cve-bin-tool-tiily948/gnu-nil-sparse-hole.tar.extracted /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents/usr/local/go/src/archive/tar/testdata/hdr-only.tar /tmp/cve-bin-tool-tiily948/hdr-only.tar.extracted 2020-07-20 17:26:27,272 - DEBUG - executor - Analyzing layer 5 2020-07-20 17:26:27,273 - DEBUG - rootfs - Running command: sudo /home/beach/TERN/ternenv/bin/cve-bin-tool -x -u now /home/beach/.tern/temp/a5eb87b130e3b9e9032b6a544e220c66cba93be2f82927728c1ee27cc15d78d8/contents cve_bin_tool.CVEDB - WARNING - Deleting cachedir /home/beach/.cache/cve-bin-tool cve_bin_tool.CVEDB - INFO - Updating CVE data. This will take a few minutes. cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2020.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2019.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2018.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2017.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2016.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2015.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2014.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2013.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2012.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2011.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2010.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2009.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2008.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2007.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2006.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2005.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2004.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2003.json.gz cve_bin_tool.cvedb.cache_update - INFO - Updating CVE cache for nvdcve-1.1-2002.json.gz cve_bin_tool.Scanner - INFO - Checkers: binutils, bluez, bzip2, cups, curl, expat, ffmpeg, gnutls, gstreamer, hostapd, icu, kerberos, libcurl, libdb, libgcrypt, libjpeg, libnss, libtiff, lighttpd, ncurses, nessus, nginx, node, openssh, openssl, openswan, png, postgresql, python, rsyslog, sqlite, strongswan, syslogng, systemd, varnish, wireshark, xerces, xml2, zlib cve_bin_tool - INFO - None cve_bin_tool - INFO - cve_bin_tool - INFO - Overall CVE summary: cve_bin_tool - INFO - There are 0 files with known CVEs detected 2020-07-20 17:33:25,214 - DEBUG - generator - Creating a detailed report of components in image... This report was generated by the Tern Project Version: 2.1.1 Docker image: golang:1.12-alpine: Layer 1: File licenses found in Layer: None Packages found in Layer: None Licenses found in Layer: None ------------------------------------------------ Layer 2: File licenses found in Layer: None Packages found in Layer: None Licenses found in Layer: None ------------------------------------------------ Layer 3: File licenses found in Layer: None Packages found in Layer: None Licenses found in Layer: None ------------------------------------------------ Layer 4: File licenses found in Layer: None Packages found in Layer: None Licenses found in Layer: None ------------------------------------------------ Layer 5: File licenses found in Layer: None Packages found in Layer: None Licenses found in Layer: None ------------------------------------------------ ########################################### # Summary of licenses found in Container: # ########################################### None 2020-07-20 17:33:25,219 - DEBUG - rootfs - Running command: sudo rm -rf /home/beach/.tern/temp/daa4253bbe5a2459c4aa33b3ccac33c06c4e055d6c1093bb477a371ed4a8eef0/contents 2020-07-20 17:33:25,244 - DEBUG - rootfs - Running command: sudo rm -rf /home/beach/.tern/temp/a4816229dbc332c74de29ac6a705ba1db243d263fe7dd0088062a4495af8672b/contents 2020-07-20 17:33:25,269 - DEBUG - rootfs - Running command: sudo rm -rf /home/beach/.tern/temp/17eef46af9e25447ee0fb79ae1b71ca951ba977994ded0c72ada109d3a0f4e93/contents 2020-07-20 17:33:25,282 - DEBUG - rootfs - Running command: sudo rm -rf /home/beach/.tern/temp/ae3c148a463d865cbb17f686e0e54c55e4a6eb360f47e61f5fb0f66e5cf86a34/contents 2020-07-20 17:33:25,691 - DEBUG - rootfs - Running command: sudo rm -rf /home/beach/.tern/temp/a5eb87b130e3b9e9032b6a544e220c66cba93be2f82927728c1ee27cc15d78d8/contents 2020-07-20 17:33:25,705 - DEBUG - run - Teardown... 2020-07-20 17:33:25,707 - DEBUG - rootfs - Running command: sudo rm -rf /home/beach/.tern/temp/mergedir 2020-07-20 17:33:25,720 - DEBUG - rootfs - Running command: sudo rm -rf /home/beach/.tern/temp/workdir 2020-07-20 17:33:25,783 - DEBUG - __main__ - Report completeTERN 分析結果について
TERNの特徴として,レイヤーごとに含まれているOSSを検出する.
このとき,以下のような簡単なコマンドを組み合わせ実行している.
(txet 形式で結果を出力するとコマンド詳細を確認できる)copyrights: in container: pkgs=`dpkg --get-selections | cut -f1 -d':' | awk '{print $1}'` for p in $pkgs; do /bin/cat /usr/share/doc/$p/copyright; echo LICF; doneライセンスやCopyrightなどの検出は、単に上記のような切り抜きコマンドをいくつか組み合わせて実行しただけである.このため,出力されるレポートではライセンスの書式などが揃っていない。
切り抜きコマンドや分析内容は以下の「TERNの分析結果例(txt形式)」に実際のものを確認できる.
TERNの分析結果例(txt形式)
Golang1.14分析結果ファイルThis report was generated by the Tern Project Version: 2.1.1 Docker image: golang:1.14: Generated with ScanCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. No content created from ScanCode should be considered or used as legal advice. Consult an Attorney for any legal advice. ScanCode is a free software code scanning tool from nexB Inc. and others. Visit https://github.com/nexB/scancode-toolkit/ for support and download. Layer 1: info: Found 'Debian GNU/Linux 10 (buster)' in /etc/os-release. info: Layer created by commands: /bin/sh -c #(nop) ADD file:1ab357efe422cfed5e37af2dc60d07ccfd4bdee4d4a0c00838b5d68f19ff20c7 in / info: Retrieved by invoking listing in command_lib/base.yml versions: in container: pkgs=`dpkg --get-selections | cut -f1 -d':' | awk '{print $1}'` for p in $pkgs; do dpkg -l $p | awk 'NR>5 {print $3}'; done copyrights: in container: pkgs=`dpkg --get-selections | cut -f1 -d':' | awk '{print $1}'` for p in $pkgs; do /bin/cat /usr/share/doc/$p/copyright; echo LICF; done names: in container: dpkg --get-selections | cut -f1 -d':' | awk '{print $1}' Invoking commands from command_lib/base.yml: warning: No listing method for 'licenses'. Additional analysis may be required. No listing method for 'srcs'. Additional analysis may be required. File licenses found in Layer: newlib-historical, gpl-2.0-plus AND lgpl-2.1-plus, latex2e, bsd-new OR gpl-1.0-plus, mit, zlib, d-zlib, agpl-3.0-plus, artistic-1.0, gfdl-1.2, fsf-mit, other-copyleft, gpl-3.0-plus OR mit, unicode, gpl-1.0-plus, x11-fsf, mpl-2.0, oracle-bsd-no-nuclear, bsd-unmodified, smail-gpl, bsd-original, bsd-axis-nomod OR gpl-1.0-plus, bsd-new, lgpl-3.0-plus OR gpl-2.0-plus, warranty-disclaimer, artistic-2.0, bsd-2-clause-plus-advertizing, gpl-2.0-plus WITH autoconf-simple-exception-2.0, x11-lucent, lgpl-2.1-plus, gpl-2.0-plus OR lgpl-2.1-plus OR mpl-1.1, gpl-3.0 AND gpl-2.0 AND lgpl-3.0-plus WITH cygwin-exception-lgpl-3.0-plus AND other-copyleft AND other-permissive, wtfpl-2.0, gpl-2.0 AND lgpl-2.0 AND bsd-new AND mit-old-style-no-advert, fsf-ap, fsf-unlimited, gpl-1.0-plus WITH autoconf-simple-exception-2.0, sleepycat, lgpl-3.0-plus, free-unknown, gpl-2.0 OR lgpl-2.1, carnegie-mellon-contributors, gpl-3.0-plus WITH bison-exception-2.2, other-permissive, gfdl-1.3, mit OR gpl-2.0, uoi-ncsa, inner-net-2.0, mpl-1.1, gfdl-1.2-plus, gpl-3.0-plus, gpl-1.0, gfdl-1.3-plus, apache-2.0, x11-xconsortium, gpl-2.0, gpl-1.0-plus OR artistic-1.0, lgpl-2.0-plus, artistic-2.0 AND public-domain-disclaimer, public-domain-disclaimer, nilsson-historical, gpl-3.0, unknown, lgpl-2.0, sunpro, bsla, lgpl-2.0-plus AND gpl-1.0-plus, historical, gpl-2.0-plus, x11-hanson, lgpl-3.0, public-domain, hs-regexp, epl-2.0 OR gpl-2.0-plus OR lgpl-2.1-plus, gcc-exception-3.1, gpl-1.0 OR gpl-2.0, gpl-3.0-plus WITH gcc-exception-3.1, gpl-2.0-plus OR mit, gfdl-1.1-plus, bsd-original-uc, artistic-1.0-cl8, libselinux-pd, ibm-dhcp, lgpl-2.1 AND gpl-2.0 AND gpl-3.0, mit-old-style-no-advert, osf-1990, autoconf-simple-exception-2.0, philippe-de-muyter, gpl-2.0 OR bsd-simplified, ietf, isc, amd-historical, autoconf-exception-2.0, gpl-3.0-plus WITH autoconf-macro-exception, rdisc, artistic-perl-1.0, ssleay-windows, bzip2-libbzip-2010, agpl-3.0, artistic-2.0 OR gpl-1.0-plus, bsd-simplified, gpl-1.0-plus OR artistic-2.0, lgpl-2.1, gpl-1.0-plus AND gpl-2.0-plus AND lgpl-2.0-plus AND gfdl-1.1, cc0-1.0, bsd-new OR gpl-2.0-plus, intel-osl-1993, tcp-wrappers Packages found in Layer: adduser-3.118, apt-1.8.2.1, base-files-10.3+deb10u4, base-passwd-3.5.46, bash-5.0-4, bsdutils-1:2.33.1-0.1, coreutils-8.30-3, dash-0.5.10.2-5, debconf-1.5.71, debian-archive-keyring-2019.1, debianutils-4.8.6.1, diffutils-1:3.7-3, dpkg-1.19.7, e2fsprogs-1.44.5-1+deb10u3, fdisk-2.33.1-0.1, findutils-4.6.0+git+20190209-2, gcc-8-base-8.3.0-6, gpgv-2.2.12-1+deb10u1, grep-3.3-1, gzip-1.9-3, hostname-3.21, init-system-helpers-1.56+nmu1, iproute2-4.20.0-2, iputils-ping-3:20180629-2+deb10u1, libacl1-2.2.53-4, libapt-pkg5.0-1.8.2.1, libattr1-1:2.4.48-4, libaudit-common-1:2.8.4-3, libaudit1-1:2.8.4-3, libblkid1-2.33.1-0.1, libbz2-1.0-1.0.6-9.2~deb10u1, libc-bin-2.28-10, libc6-2.28-10, libcap-ng0-0.7.9-2, libcap2-1:2.25-2, libcap2-bin-1:2.25-2, libcom-err2-1.44.5-1+deb10u3, libdb5.3-5.3.28+dfsg1-0.5, libdebconfclient0-0.249, libelf1-0.176-1.1, libext2fs2-1.44.5-1+deb10u3, libfdisk1-2.33.1-0.1, libffi6-3.2.1-9, libgcc1-1:8.3.0-6, libgcrypt20-1.8.4-5, libgmp10-2:6.1.2+dfsg-4, libgnutls30-3.6.7-4+deb10u4, libgpg-error0-1.35-1, libhogweed4-3.4.1-1, libidn2-0-2.0.5-1+deb10u1, liblz4-1-1.8.3-1, liblzma5-5.2.4-1, libmnl0-1.0.4-2, libmount1-2.33.1-0.1, libncursesw6-6.1+20181013-2+deb10u2, libnettle6-3.4.1-1, libp11-kit0-0.23.15-2, libpam-modules-1.3.1-5, libpam-modules-bin-1.3.1-5, libpam-runtime-1.3.1-5, libpam0g-1.3.1-5, libpcre3-2:8.39-12, libseccomp2-2.3.3-4, libselinux1-2.8-1+b1, libsemanage-common-2.8-2, libsemanage1-2.8-2, libsepol1-2.8-1, libsmartcols1-2.33.1-0.1, libss2-1.44.5-1+deb10u3, libstdc++6-8.3.0-6, libsystemd0-241-7~deb10u4, libtasn1-6-4.13-3, libtinfo6-6.1+20181013-2+deb10u2, libudev1-241-7~deb10u4, libunistring2-0.9.10-1, libuuid1-2.33.1-0.1, libxtables12-1.8.2-4, libzstd1-1.3.8+dfsg-3, login-1:4.5-1.1, mawk-1.3.3-17+b3, mount-2.33.1-0.1, ncurses-base-6.1+20181013-2+deb10u2, ncurses-bin-6.1+20181013-2+deb10u2, passwd-1:4.5-1.1, perl-base-5.28.1-6, sed-4.7-1, sysvinit-utils-2.93-8, tar-1.30+dfsg-6, tzdata-2020a-0+deb10u1, util-linux-2.33.1-0.1, zlib1g-1:1.2.11.dfsg-1 Licenses found in Layer: GPLv2+, PD, GPL-2, BSD-3-clause, LGPL, BSD-2-clause, GPL-2+, BSD-4-clause, MIT, GPL-3+, public-domain, LGPL-2.1+, LGPL-3+, LGPL-2+, public-domain-md5, public-domain-s-s-d, CC0-1.0, GPL-3+ or BSD-3-clause, Expat, TinySCHEME, permissive, RFC-Reference, LGPL-2.1, BSD-variant, BSD-3-clause or GPL-2, BSD-3-clause or GPL-2+, LGPLv3+_or_GPLv2+, Public domain., GPLv3+, g10-permissive, LGPL-2.1+ or BSD-3-clause, GAP, GPL-2+ with Autoconf exception, other, Unicode, LGPL-3+ or GPL-2+, config-h, noderivs, PD-debian, permissive-nowarranty, probably-PD, none, permissive-fsf, Autoconf, ISC, BSD-3-Clause, same-as-rest-of-p11kit, permissive-like-automake-output, GPL-2+ with distribution exception, FreeSoftware, GPL-3+ or GFDL-1.2+, GFDL-1.2+, Artistic-2, custom, zlib, BSD-3-clause and GPL-2, Expat or GPL-1+ or Artistic, BZIP, GPL-1+ or Artistic or Artistic-dist, REGCOMP, SDBM-PUBLIC-DOMAIN, HSIEH-BSD, Artistic or GPL-1+ or Artistic-dist, GPL-1+ or Artistic, DONT-CHANGE-THE-GPL, BSD-4-clause-POWERDOG, GPL-1+ or Artistic, and Unicode, HSIEH-DERIVATIVE, ZLIB, GPL-3+-WITH-BISON-EXCEPTION, Artistic, S2P, Artistic-dist, GPL-1+ or Artistic, and Expat, BSD-3-clause-GENERIC, RRA-KEEP-THIS-NOTICE, TEXT-TABS, REGCOMP, and GPL-1+ or Artistic, GPL-1+ or Artistic, and BSD-3-clause-GENERIC, BSD-3-clause-with-weird-numbering, GPL-1+ or Artistic, and BSD-4-clause-POWERDOG, GPL-2+ or Artistic, GPL-1+, Zlib ------------------------------------------------ Layer 2: info: Instruction Line: RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl netbase wget && rm -rf /var/lib/apt/lists/* warning: Ignored Commands:apt-get update Unrecognized Commands:rm -rf /var/lib/apt/lists/* info: Layer created by commands: /bin/sh -c apt-get update && apt-get install -y --no-install-recommends ca-certificates curl netbase wget && rm -rf /var/lib/apt/lists/* info: Retrieved by invoking listing in command_lib/base.yml versions: in container: pkgs=`dpkg --get-selections | cut -f1 -d':' | awk '{print $1}'` for p in $pkgs; do dpkg -l $p | awk 'NR>5 {print $3}'; done copyrights: in container: pkgs=`dpkg --get-selections | cut -f1 -d':' | awk '{print $1}'` for p in $pkgs; do /bin/cat /usr/share/doc/$p/copyright; echo LICF; done names: in container: dpkg --get-selections | cut -f1 -d':' | awk '{print $1}' Invoking commands from command_lib/base.yml: warning: No listing method for 'licenses'. Additional analysis may be required. No listing method for 'srcs'. Additional analysis may be required. File licenses found in Layer: ibm-dhcp, lgpl-2.1-plus, mit-old-style-no-advert, gpl-2.0-plus OR lgpl-2.1-plus OR mpl-1.1, gpl-2.0, gpl-3.0 AND other-copyleft, lgpl-2.0-plus, fsf-ap, mit, curl, openssl-exception-gpl-2.0, gpl-3.0, ietf, isc, unknown, rsa-md4, ofl-1.1, free-unknown, gfdl-1.2, fsf-mit, lgpl-2.0, bsla, other-permissive, cc-by-sa-3.0, hs-regexp-orig, gpl-3.0-plus WITH autoconf-macro-exception, other-copyleft, gpl-3.0-plus OR mit, x11-fsf, rsa-md5, gpl-1.0-plus, ofl-1.1 AND mit, gpl-2.0-plus, mpl-2.0, lgpl-3.0, public-domain, gpl-1.0-plus OR lgpl-2.0-plus OR bsd-simplified, bsd-x11, bzip2-libbzip-2010, mit-no-advert-export-control, mit-license-1998, bsd-original, openssl-ssleay, bsd-simplified, gpl-3.0-plus, bsd-new, michigan-disclaimer, xfree86-1.0, bsd-plus-mod-notice, openldap-2.8, openssl, bsd-original-uc, rsa-1990, bsd-2-clause-plus-advertizing Packages found in Layer: ca-certificates-20200601~deb10u1, curl-7.64.0-4+deb10u1, libcurl4-7.64.0-4+deb10u1, libgssapi-krb5-2-1.17-3, libk5crypto3-1.17-3, libkeyutils1-1.6-6, libkrb5-3-1.17-3, libkrb5support0-1.17-3, libldap-2.4-2-2.4.47+dfsg-3+deb10u2, libldap-common-2.4.47+dfsg-3+deb10u2, libnghttp2-14-1.36.0-2+deb10u1, libpcre2-8-0-10.32-5, libpsl5-0.20.2-2, librtmp1-2.4+20151223.gitfa8646d.1-2, libsasl2-2-2.1.27+dfsg-1+deb10u1, libsasl2-modules-db-2.1.27+dfsg-1+deb10u1, libssh2-1-1.8.0-2.1, libssl1.1-1.1.1d-0+deb10u3, netbase-5.6, openssl-1.1.1d-0+deb10u3, wget-1.20.1-1.1 Licenses found in Layer: GPL-2+, MPL-2.0, ISC, curl, BSD-4-Clause, BSD-3-Clause, public-domain, other, LGPL-2+, BSD-2-clause, Expat, MIT, all-permissive, GPL-3+ with autoconf exception, SIL-OFL-1.1, Chromium, GPL-3+, BSD-4-clause, BSD3 ------------------------------------------------ Layer 3: info: Instruction Line: RUN set -ex; if ! command -v gpg > /dev/null; then apt-get update; apt-get install -y --no-install-recommends gnupg dirmngr ; rm -rf /var/lib/apt/lists/*; fi warning: Unrecognized Commands:set -ex File licenses found in Layer: lgpl-2.1-plus, x11-xconsortium, gpl-2.0, lgpl-2.0-plus, fsf-unlimited, gpl-1.0-plus WITH autoconf-simple-exception-2.0, philippe-de-muyter, mit, public-domain-disclaimer, gpl-3.0, gpl-2.0-plus AND gpl-3.0, ietf, lgpl-3.0-plus, unknown, free-unknown, fsf-mit, other-permissive, other-copyleft, gpl-1.0-plus, gpl-2.0-plus, lgpl-3.0, public-domain, gfdl-1.2-plus, gpl-3.0-plus, gpl-2.0-plus OR lgpl-3.0-plus, bsd-new, lgpl-2.1, gpl-2.0-plus WITH libtool-exception-2.0, cc0-1.0, gfdl-1.3-plus, libtool-exception-2.0 Packages found in Layer: None Licenses found in Layer: None ------------------------------------------------ Layer 4: info: Instruction Line: RUN apt-get update && apt-get install -y --no-install-recommends git mercurial openssh-client subversion procps && rm -rf /var/lib/apt/lists/* warning: Ignored Commands:apt-get update Unrecognized Commands:rm -rf /var/lib/apt/lists/* info: Layer created by commands: /bin/sh -c apt-get update && apt-get install -y --no-install-recommends git mercurial openssh-client subversion procps && rm -rf /var/lib/apt/lists/* info: Retrieved by invoking listing in command_lib/base.yml versions: in container: pkgs=`dpkg --get-selections | cut -f1 -d':' | awk '{print $1}'` for p in $pkgs; do dpkg -l $p | awk 'NR>5 {print $3}'; done copyrights: in container: pkgs=`dpkg --get-selections | cut -f1 -d':' | awk '{print $1}'` for p in $pkgs; do /bin/cat /usr/share/doc/$p/copyright; echo LICF; done names: in container: dpkg --get-selections | cut -f1 -d':' | awk '{print $1}' Invoking commands from command_lib/base.yml: warning: No listing method for 'licenses'. Additional analysis may be required. No listing method for 'srcs'. Additional analysis may be required. File licenses found in Layer: mpl-1.1 OR lgpl-2.1-plus OR apache-2.0, python-cwi, mit OR gpl-1.0-plus, mit, python OR gpl-2.0, zlib, agpl-3.0-plus, gfdl-1.2, fsf-mit, python, other-copyleft, cc-pd, unicode, bsd-unchanged, generic-cla, gpl-2.0 AND epl-1.0, gpl-1.0-plus, mpl-1.0, x11-fsf, qpl-1.0, sfl-license, bsd-original, bsd-new, warranty-disclaimer, openssl, apache-1.1, apache-2.0 OR apache-1.1, snprintf, artistic-2.0, bsd-2-clause-plus-advertizing, lgpl-2.1-plus, unknown-license-reference, fsf-ap, bsd-simplified AND gpl-2.0, svndiff, free-unknown, beerware, gpl-3.0-plus WITH bison-exception-2.2, other-permissive, cmu-uc, gfdl-1.3, llnl, cnri-python-1.6, rsa-md5, mit OR gpl-2.0, mpl-1.1, gpl-3.0-plus, gpl-1.0, fsf-free, gfdl-1.3-plus, tatu-ylonen, apache-2.0, x11-xconsortium, gpl-2.0, gpl-1.0-plus OR artistic-1.0, lgpl-2.0-plus, artistic-2.0 AND public-domain-disclaimer, curl, public-domain-disclaimer, gpl-3.0, unknown, lgpl-2.0, sun-sissl-1.1, hs-regexp-orig, m-plus, proprietary-license, historical, gpl-2.0-plus, lgpl-3.0, public-domain, zpl-2.1, afl-3.0, boost-1.0, artistic-2.0 OR bsd-new OR lgpl-3.0, gfdl-1.1-plus, bsd-original-uc, artistic-1.0-cl8, pygres-2.2, mit-old-style-no-advert, bsd-simplified-darwin, philippe-de-muyter, gpl-2.0 OR bsd-new, isc, public-domain AND gpl-2.0-plus, artistic-perl-1.0, bzip2-libbzip-2010, agpl-3.0, artistic-2.0 OR gpl-1.0-plus, bsd-simplified, openssl-ssleay, gpl-1.0-plus OR artistic-2.0, tested-software, lgpl-2.1, gpl-1.0-plus OR bsd-simplified, cc0-1.0, x11, bsd-2-clause-netbsd Packages found in Layer: dirmngr-2.2.12-1+deb10u1, git-1:2.20.1-2+deb10u3, git-man-1:2.20.1-2+deb10u3, gnupg-2.2.12-1+deb10u1, gnupg-l10n-2.2.12-1+deb10u1, gnupg-utils-2.2.12-1+deb10u1, gpg-2.2.12-1+deb10u1, gpg-agent-2.2.12-1+deb10u1, gpg-wks-client-2.2.12-1+deb10u1, gpg-wks-server-2.2.12-1+deb10u1, gpgconf-2.2.12-1+deb10u1, gpgsm-2.2.12-1+deb10u1, libapr1-1.6.5-1+b1, libaprutil1-1.6.1-4, libassuan0-2.5.2-1, libbsd0-0.9.1-2, libcurl3-gnutls-7.64.0-4+deb10u1, libedit2-3.1-20181209-1, liberror-perl-0.17027-2, libexpat1-2.2.6-2+deb10u1, libgdbm-compat4-1.18.1-4, libgdbm6-1.18.1-4, libksba8-1.3.5-2, libncurses6-6.1+20181013-2+deb10u2, libnpth0-1.6-1, libperl5.28-5.28.1-6, libprocps7-2:3.3.15-2, libpython-stdlib-2.7.16-1, libpython2-stdlib-2.7.16-1, libpython2.7-minimal-2.7.16-2+deb10u1, libpython2.7-stdlib-2.7.16-2+deb10u1, libreadline7-7.0-5, libserf-1-1-1.3.9-7+b10, libsqlite3-0-3.27.2-3, libsvn1-1.10.4-1+deb10u1, libutf8proc2-2.3.0-1, lsb-base-10.2019051400, mercurial-4.8.2-1+deb10u1, mercurial-common-4.8.2-1+deb10u1, mime-support-3.62, openssh-client-1:7.9p1-10+deb10u2, perl-5.28.1-6, perl-modules-5.28-5.28.1-6, pinentry-curses-1.1.0-2, procps-2:3.3.15-2, python-2.7.16-1, python-minimal-2.7.16-1, python2-2.7.16-1, python2-minimal-2.7.16-1, python2.7-2.7.16-2+deb10u1, python2.7-minimal-2.7.16-2+deb10u1, readline-common-7.0-5, sensible-utils-0.0.12, subversion-1.10.4-1+deb10u1, ucf-3.0038+nmu1 Licenses found in Layer: BSD-3-clause, CC0-1.0, GPL-3+ or BSD-3-clause, Expat, GPL-3+, TinySCHEME, LGPL-3+, permissive, LGPL-2.1+, RFC-Reference, ISC, BSD-2-clause, LGPL-2+, EDL-1.0, GPL-2, mingw-runtime, Apache-2.0, dlmalloc, Boost, GPL-2+, GPL-1+ or Artistic-1, GAP, GAP~FSF, GPL-2+ with libtool exception, BSD-5-clause-Peter-Wemm, BSD-3-clause-Regents, ISC-Original, BSD-4-clause-Niels-Provos, BSD-3-clause-Regents and BSD-2-clause-NetBSD, Beerware, BSD-2-clause-NetBSD, BSD-3-clause-John-Birrell, public-domain, BSD-2-clause-author, BSD-2-clause-verbatim, BSD-3-clause-author, public-domain-Colin-Plumb, BSD-4-clause-Christopher-G-Demetriou, curl, BSD-4-Clause, BSD-3-Clause, other, Artistic, MIT/X11, GPL-1+, Artistic or GPL-1+, MIT, GFDL-NIV-1.3+, Expat or GPL-1+ or Artistic, BZIP, GPL-1+ or Artistic or Artistic-dist, REGCOMP, SDBM-PUBLIC-DOMAIN, HSIEH-BSD, Artistic or GPL-1+ or Artistic-dist, GPL-1+ or Artistic, DONT-CHANGE-THE-GPL, LGPL-2.1, BSD-4-clause-POWERDOG, GPL-1+ or Artistic, and Unicode, HSIEH-DERIVATIVE, Artistic-2, ZLIB, GPL-3+-WITH-BISON-EXCEPTION, Unicode, S2P, Artistic-dist, GPL-1+ or Artistic, and Expat, BSD-3-clause-GENERIC, RRA-KEEP-THIS-NOTICE, TEXT-TABS, REGCOMP, and GPL-1+ or Artistic, GPL-1+ or Artistic, and BSD-3-clause-GENERIC, BSD-3-clause-with-weird-numbering, GPL-1+ or Artistic, and BSD-4-clause-POWERDOG, GPL-2+ or Artistic, LGPL-2.0+, GPL-2.0+, # Licensed to PSF under a Contributor Agreement, PSF-2, Apache-2, This software is provided 'as-is', without any express or implied, This software is provided as-is, without express or implied, see above, some license as Python., Permission is hereby granted, free of charge, to any person obtaining, Python, Apache, Zlib, Expat and Unicode, Utfwidth, Svnwrap, BSD-3-clause or Apache-2.0, AFL-3, Zope Public License (ZPL) Version 2.1, Permission is hereby granted, free of charge, to any person obtaining a copy of this, Permission is hereby granted, free of charge, to any person obtaining a copy, Redistribution and use in source and binary forms, with or without modification,, PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2, Bellcore, ad-hoc, Expat-with-advertising-restriction, Beer-ware, Powell-BSD-style, Mazieres-BSD-style, OpenSSH, X11, LGPL-3+ or GPL-2+, All-permissive, installsh, configure ------------------------------------------------ Layer 5: info: Instruction Line: RUN apt-get update && apt-get install -y --no-install-recommends g++ gcc libc6-dev make pkg-config && rm -rf /var/lib/apt/lists/* warning: Ignored Commands:apt-get update Unrecognized Commands:rm -rf /var/lib/apt/lists/* info: Layer created by commands: /bin/sh -c apt-get update && apt-get install -y --no-install-recommends g++ gcc libc6-dev make pkg-config && rm -rf /var/lib/apt/lists/* info: Retrieved by invoking listing in command_lib/base.yml versions: in container: pkgs=`dpkg --get-selections | cut -f1 -d':' | awk '{print $1}'` for p in $pkgs; do dpkg -l $p | awk 'NR>5 {print $3}'; done copyrights: in container: pkgs=`dpkg --get-selections | cut -f1 -d':' | awk '{print $1}'` for p in $pkgs; do /bin/cat /usr/share/doc/$p/copyright; echo LICF; done names: in container: dpkg --get-selections | cut -f1 -d':' | awk '{print $1}' Invoking commands from command_lib/base.yml: warning: No listing method for 'licenses'. Additional analysis may be required. No listing method for 'srcs'. Additional analysis may be required. File licenses found in Layer: gpl-2.0-plus WITH autoconf-simple-exception-2.0, mpl-1.1 OR gpl-2.0 OR lgpl-2.1, gpl-1.0-plus WITH linux-syscall-exception-gpl, mit-old-style, gpl-2.0 WITH linux-syscall-exception-gpl OR bsd-simplified, lgpl-2.1-plus, apache-2.0, mit-old-style-no-advert, gpl-2.0, gpl-2.0 WITH linux-syscall-exception-gpl OR linux-openib, lgpl-2.0-plus, fsf-ap, mit, gpl-2.0 WITH linux-syscall-exception-gpl, gpl-3.0, boost-original, gpl-2.0 OR bsd-simplified, gpl-2.0 OR bsd-new, ietf, isc, unknown, lgpl-3.0-plus, commercial-license OR gpl-3.0, agpl-3.0-plus, free-unknown, gfdl-1.2, carnegie-mellon-contributors, sunpro, lgpl-2.0, gpl-2.0 OR linux-openib, other-permissive, gpl-2.0-plus WITH linux-syscall-exception-gpl OR bsd-new, gpl-2.0 WITH linux-syscall-exception-gpl OR mit, lgpl-2.0-plus WITH linux-syscall-exception-gpl, other-copyleft, gpl-3.0-plus OR mit, unicode, khronos, gpl-2.0 OR cddl-1.0, historical, ruby, gpl-1.0-plus, gpl-2.0-plus, uoi-ncsa, lgpl-3.0, gpl-2.0 OR anu-license, inner-net-2.0, public-domain, gpl-2.0 WITH linux-syscall-exception-gpl AND mit, hs-regexp, lgpl-2.0 OR mulle-kybernetik, gpl-2.0 OR mit, bsd-new OR gpl-2.0, gpl-2.0 WITH linux-syscall-exception-gpl OR bsd-new, gfdl-1.2-plus, bsd-original, bsd-simplified, gpl-3.0-plus, gpl-2.0-plus WITH linux-syscall-exception-gpl, boost-1.0, lgpl-2.1, bsd-new, warranty-disclaimer, gpl-2.0-plus OR bsd-new, gpl-2.0-plus WITH mif-exception, bsd-new OR gpl-2.0-plus, gpl-3.0-plus WITH gcc-exception-3.1, gpl-2.0-plus OR mit, gfdl-1.1-plus, lgpl-2.1 WITH linux-syscall-exception-gpl, lgpl-2.1-plus WITH linux-syscall-exception-gpl Packages found in Layer: binutils-2.31.1-16, binutils-common-2.31.1-16, binutils-x86-64-linux-gnu-2.31.1-16, cpp-4:8.3.0-1, cpp-8-8.3.0-6, g++-4:8.3.0-1, g++-8-8.3.0-6, gcc-4:8.3.0-1, gcc-8-8.3.0-6, libasan5-8.3.0-6, libatomic1-8.3.0-6, libbinutils-2.31.1-16, libc-dev-bin-2.28-10, libc6-dev-2.28-10, libcc1-0-8.3.0-6, libdpkg-perl-1.19.7, libgcc-8-dev-8.3.0-6, libglib2.0-0-2.58.3-2+deb10u2, libgomp1-8.3.0-6, libisl19-0.20-2, libitm1-8.3.0-6, liblsan0-8.3.0-6, libmpc3-1.1.0-1, libmpfr6-4.0.2-1, libmpx2-8.3.0-6, libquadmath0-8.3.0-6, libstdc++-8-dev-8.3.0-6, libtsan0-8.3.0-6, libubsan1-8.3.0-6, linux-libc-dev-4.19.118-2+deb10u1, make-4.2.1-1.2, pkg-config-0.29-6 Licenses found in Layer: BSD-2-clause, GPL-2, public-domain-md5, GPL-2+, public-domain-s-s-d, Apache-2.0, Expat, This version was made by modifying the master file made by, MIT, Permission is hereby granted, free of charge, to any person obtaining a copy, LGPL-2.1+, CRYPTOGAMS, LGPL-2.1, Xen-interface, GPL-2+ or X11, Unicode-data, GPL-3+ ------------------------------------------------ Layer 6: info: Instruction Line: RUN set -eux; dpkgArch="$(dpkg --print-architecture)"; case "${dpkgArch##*-}" in amd64) goRelArch='linux-amd64'; goRelSha256='aed845e4185a0b2a3c3d5e1d0a35491702c55889192bb9c30e67a3de6849c067' ;; armhf) goRelArch='linux-armv6l'; goRelSha256='e20211425b3f797ca6cd5e9a99ab6d5eaf1b009d08d19fc8a7835544fa58c703' ;; arm64) goRelArch='linux-arm64'; goRelSha256='05dc46ada4e23a1f58e72349f7c366aae2e9c7a7f1e7653095538bc5bba5e077' ;; i386) goRelArch='linux-386'; goRelSha256='4179f406ea0efd455a8071eaaaf1dea92cac5c17aab89fbad18ea2a37623c810' ;; ppc64el) goRelArch='linux-ppc64le'; goRelSha256='b335f85bc935ca3f553ad1bac37da311aaec887ffd8a48cb58a0abb0d8adf324' ;; s390x) goRelArch='linux-s390x'; goRelSha256='17f2ae0bae968b3d909daabc5cc4a37471ddb70ec49076b78702291e6772d71a' ;; *) goRelArch='src'; goRelSha256='7011af3bbc2ac108d1b82ea8abb87b2e63f78844f0259be20cde4d42c5c40584'; echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; esac; url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; wget -O go.tgz "$url" --progress=dot:giga; echo "${goRelSha256} *go.tgz" | sha256sum -c -; tar -C /usr/local -xzf go.tgz; rm go.tgz; if [ "$goRelArch" = 'src' ]; then savedAptMark="$(apt-mark showmanual)"; apt-get update; apt-get install -y --no-install-recommends golang-go; goEnv="$(go env | sed -rn -e '/^GO(OS|ARCH|ARM|386)=/s//export \0/p')"; eval "$goEnv"; [ -n "$GOOS" ]; [ -n "$GOARCH" ]; ( cd /usr/local/go/src; ./make.bash; ); apt-mark auto '.*' > /dev/null; apt-mark manual $savedAptMark > /dev/null; apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; rm -rf /var/lib/apt/lists/*; go install std; rm -rf /usr/local/go/pkg/*/cmd /usr/local/go/pkg/bootstrap /usr/local/go/pkg/obj /usr/local/go/pkg/tool/*/api /usr/local/go/pkg/tool/*/go_bootstrap /usr/local/go/src/cmd/dist/dist ; fi; go version warning: Unrecognized Commands:set -eux wget -O go.tgz $url --progress=dot:giga echo ${goRelSha256} *go.tgz | sha256sum -c - tar -C /usr/local -xzf go.tgz rm go.tgz go version File licenses found in Layer: multics, bsd-new AND google-patent-license-webm, apache-2.0, cc-by-3.0, ijg, gpl-2.0, unknown-license-reference, mit, public-domain-disclaimer, gpl-3.0, red-hat-attribution, ekioh, unknown, sunpro, other-permissive, openssl-ssleay OR bsd-new, generic-cla, gpl-1.0-plus, gpl-2.0-plus, apple-attribution, public-domain, bsd-simplified OR gpl-2.0, bsd-2-clause-freebsd, google-patent-license-golang, bsd-simplified, bsd-new, bsd-1-clause, mpeg-ssg Packages found in Layer: None Licenses found in Layer: None ------------------------------------------------ Layer 7: info: Instruction Line: RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" warning: Unrecognized Commands:mkdir -p $GOPATH/src $GOPATH/bin chmod -R 777 $GOPATH File licenses found in Layer: None Packages found in Layer: None Licenses found in Layer: None ------------------------------------------------ ########################################### # Summary of licenses found in Container: # ########################################### config-h, mpl-1.1 OR lgpl-2.1-plus OR apache-2.0, newlib-historical, gpl-2.0-plus AND lgpl-2.1-plus, Artistic or GPL-1+ or Artistic-dist, GPL-3+ or GFDL-1.2+, khronos, ruby, mpl-2.0, bsd-simplified OR gpl-2.0, gpl-2.0 WITH linux-syscall-exception-gpl AND mit, permissive-like-automake-output, gpl-1.0-plus OR lgpl-2.0-plus OR bsd-simplified, mit-no-advert-export-control, gpl-2.0 WITH linux-syscall-exception-gpl OR bsd-new, BSD-3-clause-John-Birrell, GAP~FSF, bsd-2-clause-plus-advertizing, lgpl-2.1-plus WITH linux-syscall-exception-gpl, Public domain., Python, wtfpl-2.0, unknown-license-reference, SDBM-PUBLIC-DOMAIN, GPL-1+ or Artistic, gpl-2.0-plus AND gpl-3.0, rsa-md4, free-unknown, gpl-2.0 OR lgpl-2.1, beerware, gfdl-1.3, gpl-2.0 OR cddl-1.0, llnl, cnri-python-1.6, Utfwidth, public-domain-s-s-d, xfree86-1.0, gpl-1.0, Autoconf, g10-permissive, PSF-2, apache-2.0, ijg, lgpl-2.0-plus, LGPL, curl, CC0-1.0, Expat-with-advertising-restriction, GPL-2, lgpl-2.0, sunpro, bsla, m-plus, lgpl-2.0-plus AND gpl-1.0-plus, historical, Bellcore, TEXT-TABS, afl-3.0, gcc-exception-3.1, gpl-2.0-plus WITH mif-exception, gpl-2.0-plus WITH libtool-exception-2.0, gpl-3.0-plus WITH gcc-exception-3.1, libselinux-pd, ibm-dhcp, pygres-2.2, TinySCHEME, gpl-3.0 AND other-copyleft, bsd-simplified-darwin, autoconf-simple-exception-2.0, philippe-de-muyter, LGPL-2.1, gpl-2.0 OR bsd-new, ekioh, ietf, public-domain AND gpl-2.0-plus, Apache, GPL-2+ with libtool exception, rdisc, Boost, agpl-3.0, GPL-1+ or Artistic, and BSD-3-clause-GENERIC, artistic-2.0 OR gpl-1.0-plus, openssl-ssleay, Powell-BSD-style, bsd-new OR gpl-2.0-plus, lgpl-2.1 WITH linux-syscall-exception-gpl, Expat or GPL-1+ or Artistic, LGPL-3+ or GPL-2+, BZIP, BSD-2-clause-author, red-hat-attribution, d-zlib, Redistribution and use in source and binary forms, with or without modification,, same-as-rest-of-p11kit, other-copyleft, unicode, generic-cla, mpl-1.0, ofl-1.1 AND mit, gpl-2.0 OR anu-license, bsd-unmodified, Artistic or GPL-1+, OpenSSH, SIL-OFL-1.1, BSD-4-clause, other, bsd-original, EDL-1.0, BSD-2-clause-NetBSD, GPL-2+ or Artistic, openssl, rsa-1990, GPLv3+, mpeg-ssg, GPL-2+ with distribution exception, bsd-new AND google-patent-license-webm, MIT, gpl-3.0 AND gpl-2.0 AND lgpl-3.0-plus WITH cygwin-exception-lgpl-3.0-plus AND other-copyleft AND other-permissive, svndiff, BSD-2-clause, sleepycat, BSD-4-clause-Niels-Provos, carnegie-mellon-contributors, ISC-Original, mit OR gpl-2.0, bsd-x11, REGCOMP, and GPL-1+ or Artistic, CRYPTOGAMS, Expat, GPL-1+ or Artistic, and BSD-4-clause-POWERDOG, GPL-3+ with autoconf exception, Apache-2, BSD-3-clause or GPL-2, GPL-3+, public-domain-md5, x11-xconsortium, all-permissive, GFDL-1.2+, public-domain-disclaimer, nilsson-historical, gpl-3.0, PD-debian, Artistic-2, sun-sissl-1.1, gpl-2.0-plus WITH linux-syscall-exception-gpl OR bsd-new, GPL-3+ or BSD-3-clause, PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2, gpl-2.0-plus, Artistic-dist, x11-hanson, apple-attribution, hs-regexp, permissive, bsd-new OR gpl-2.0, boost-1.0, bsd-plus-mod-notice, gpl-2.0-plus OR mit, MIT/X11, artistic-1.0-cl8, BSD3, gpl-2.0 OR bsd-simplified, isc, BSD-3-clause and GPL-2, GPL-3+-WITH-BISON-EXCEPTION, autoconf-exception-2.0, gpl-2.0 WITH linux-syscall-exception-gpl OR mit, lgpl-2.0-plus WITH linux-syscall-exception-gpl, artistic-perl-1.0, permissive-nowarranty, RRA-KEEP-THIS-NOTICE, gpl-2.0 OR mit, google-patent-license-golang, RFC-Reference, BSD-4-clause-Christopher-G-Demetriou, bsd-simplified, lgpl-2.1, ad-hoc, LGPLv3+_or_GPLv2+, GPL-1+, python-cwi, mit OR gpl-1.0-plus, latex2e, GPL-1+ or Artistic or Artistic-dist, bsd-new OR gpl-1.0-plus, HSIEH-BSD, python OR gpl-2.0, zlib, This software is provided 'as-is', without any express or implied, agpl-3.0-plus, artistic-1.0, fsf-mit, python, LGPL-2.1+, cc-pd, Artistic, gpl-3.0-plus OR mit, bsd-unchanged, BSD-3-clause-Regents, gpl-2.0 AND epl-1.0, S2P, oracle-bsd-no-nuclear, qpl-1.0, gpl-2.0-plus OR lgpl-3.0-plus, Beer-ware, warranty-disclaimer, FreeSoftware, apache-1.1, bsd-1-clause, snprintf, mpl-1.1 OR gpl-2.0 OR lgpl-2.1, mit-old-style, Permission is hereby granted, free of charge, to any person obtaining a copy of this, Apache-2.0, AFL-3, REGCOMP, gpl-2.0 AND lgpl-2.0 AND bsd-new AND mit-old-style-no-advert, fsf-ap, bsd-simplified AND gpl-2.0, BSD-4-clause-POWERDOG, HSIEH-DERIVATIVE, All-permissive, gpl-2.0 OR linux-openib, gpl-3.0-plus WITH bison-exception-2.2, cmu-uc, Unicode, uoi-ncsa, GPL-1+ or Artistic, and Expat, inner-net-2.0, Expat and Unicode, openldap-2.8, fsf-free, gfdl-1.3-plus, This software is provided as-is, without express or implied, gpl-1.0-plus OR artistic-1.0, BSD-3-clause or GPL-2+, artistic-2.0 AND public-domain-disclaimer, BSD-3-clause, GPL-2.0+, boost-original, custom, hs-regexp-orig, lgpl-3.0, see above, some license as Python., LGPL-3+, zpl-2.1, epl-2.0 OR gpl-2.0-plus OR lgpl-2.1-plus, gpl-1.0 OR gpl-2.0, GPLv2+, artistic-2.0 OR bsd-new OR lgpl-3.0, Xen-interface, BSD-2-clause-verbatim, bsd-original-uc, Zope Public License (ZPL) Version 2.1, lgpl-2.1 AND gpl-2.0 AND gpl-3.0, GPL-2+, GFDL-NIV-1.3+, GPL-1+ or Artistic, and Unicode, Svnwrap, commercial-license OR gpl-3.0, amd-historical, permissive-fsf, # Licensed to PSF under a Contributor Agreement, cc-by-sa-3.0, gpl-3.0-plus WITH autoconf-macro-exception, BSD-4-Clause, LGPL-2.0+, noderivs, tested-software, GPL-2+ or X11, gpl-1.0-plus OR bsd-simplified, gpl-1.0-plus AND gpl-2.0-plus AND lgpl-2.0-plus AND gfdl-1.1, mingw-runtime, none, bsd-2-clause-netbsd, gpl-1.0-plus WITH linux-syscall-exception-gpl, gpl-2.0 WITH linux-syscall-exception-gpl OR bsd-simplified, installsh, mit, DONT-CHANGE-THE-GPL, gfdl-1.2, openssl-ssleay OR bsd-new, LGPL-2+, gpl-1.0-plus, x11-fsf, smail-gpl, sfl-license, bsd-axis-nomod OR gpl-1.0-plus, BSD-3-clause-with-weird-numbering, bsd-new, lgpl-3.0-plus OR gpl-2.0-plus, BSD-3-clause or Apache-2.0, GPL-2+ with Autoconf exception, apache-2.0 OR apache-1.1, artistic-2.0, libtool-exception-2.0, gpl-2.0-plus WITH autoconf-simple-exception-2.0, x11-lucent, lgpl-2.1-plus, gpl-2.0-plus OR lgpl-2.1-plus OR mpl-1.1, cc-by-3.0, Unicode-data, gpl-2.0 WITH linux-syscall-exception-gpl OR linux-openib, BSD-3-clause-author, fsf-unlimited, gpl-1.0-plus WITH autoconf-simple-exception-2.0, ISC, gpl-2.0 WITH linux-syscall-exception-gpl, This version was made by modifying the master file made by, lgpl-3.0-plus, ZLIB, other-permissive, rsa-md5, BSD-3-Clause, BSD-3-clause-GENERIC, Permission is hereby granted, free of charge, to any person obtaining a copy, GAP, mpl-1.1, gfdl-1.2-plus, Chromium, gpl-3.0-plus, gpl-2.0-plus WITH linux-syscall-exception-gpl, gpl-2.0-plus OR bsd-new, GPL-1+ or Artistic-1, tatu-ylonen, multics, gpl-2.0, unknown, Mazieres-BSD-style, PD, MPL-2.0, proprietary-license, public-domain, dlmalloc, bsd-2-clause-freebsd, X11, gfdl-1.1-plus, mit-old-style-no-advert, LGPL-2.1+ or BSD-3-clause, probably-PD, osf-1990, BSD-variant, Zlib, openssl-exception-gpl-2.0, ofl-1.1, BSD-3-clause-Regents and BSD-2-clause-NetBSD, Beerware, ssleay-windows, configure, bzip2-libbzip-2010, lgpl-2.0 OR mulle-kybernetik, BSD-5-clause-Peter-Wemm, mit-license-1998, gpl-1.0-plus OR artistic-2.0, michigan-disclaimer, cc0-1.0, Permission is hereby granted, free of charge, to any person obtaining, intel-osl-1993, public-domain-Colin-Plumb, tcp-wrappers, x11TERNのレポートの形式には標準のtxt形式のほかにyaml, json, htmlなどがあるが,以下でhtmlの結果の一部を紹介する.
- TERNの分析結果例(html形式)
おわりに
Docker containers: What are the open source licensing considerations?
By The Linux FoundationApril 24, 2020といった記事が公開されている.このようなツールの開発が加速されている背景には,急激なコンテナの普及に伴うOSSコンプライアンス処理の複雑化がある.Docker コンテナを配布するとき,コンプライアンス上,配布しているOSSが何か明確にする必要がある.特にユーザがイメージの中に含んでいることを意識しにくいOSSを配布することもあるといった点には最新の注意を払わないといけない.
例えば新しいレイヤーにOSSの新バージョンをインストールした場合,一見古いバージョンのOSSは削除されているように見える.配布するイメージには旧バージョンのOSSも含まれており,これらのライセンスがバージョンで変更される場合はライセンスに関してかなり注意深く確認を行う必要がある.
現在OpenChain界隈でも,オープンソースコンプライアンスの話題として,Dockerなどのようなコンテナやイメージを配布する場合にどうするか,という議論がある.現時点でツールで解決できる課題は限られているが,TERNをはじめこれから様々なツールが開発されていくであろう.引き続き動向を確認しQiitaなどにまとめていきたい.
詳細については以下を確認するとよい.
Docker Containers for Legal Professionals Author: Armijn Hemel, MSc.その他,DockerイメージをはじめOSSコンプライアンスについて以下で議論される情報も参考にできる.
- 投稿日:2020-07-20T18:32:04+09:00
Docker Private Registry with Let's Encrypt on Ubuntu 20.04
はじめに
DockerのプライベートRegistryを作る方法。Let's Encryptも使う。
サイトでApacheやNginxなど導入すると書いてあるところがあったけど、大げさなので利用しない。
なるべくシンプルな方法を記載。certbotは次の通りインストール
$ sudo add-apt-repository ppa:certbot/certbot -y $ sudo apt update $ sudo apt install certbot -yDockerは公式のインストール方法を推奨する。
https://docs.docker.com/engine/install/ubuntu/Docker レジストリの作成
# 以下は全部rootでやる $ sudo su # certbotでファイルを取得 $ certbot certonly --standalone --preferred-challenges http --non-interactive --staple-ocsp --agree-tos -m dev@octopt.com -d registry.octopt.com # Let's Encryptの自動更新の設定 $ cat <<EOF > /etc/cron.d/letencrypt SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 30 2 * * 1 root /usr/bin/certbot renew >> /var/log/letsencrypt-renew.log && cd /etc/letsencrypt/live/example.com && cp privkey.pem domain.key && cat cert.pem chain.pem > domain.crt && chmod 777 domain.* EOF # SSL certificatesのリネーム $ cd /etc/letsencrypt/live/registry.octopt.com && \ cp privkey.pem domain.key && \ cat cert.pem chain.pem > domain.crt && \ chmod 777 domain.* #ログインしてPushするようにする。usernameはfoouser, passwordはbazzpassとする。 $ mkdir -p /mnt/docker-registry $ docker run --entrypoint htpasswd registry:latest -Bbn foouser bazzpass > /mnt/docker-registry/passfile docker run -d -p 443:5000 --restart=always --name registry \ -v /etc/letsencrypt/live/registry.octopt.com:/certs \ -v /mnt/docker-registry:/var/lib/registry \ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \ -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \ -e REGISTRY_AUTH=htpasswd \ -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \ -e REGISTRY_AUTH_HTPASSWD_PATH=/var/lib/registry/passfile \ registry:2.7.0以上。
ポート443は開けておくこと。
外部から無事できているか確認してみる。$ curl https://foouser:bazzpass@registry.octopt.com/v2/_catalog
{"repositories":[]}
がかえってこればOKPushしてみる
まずdocker ログインする必要がある。
$ docker login -u foouser -p bazzpass registry.octopt.com:443 WARNING! Using --password via the CLI is insecure. Use --password-stdin. Login Succeededとなる。その後はPushできる。手元にあったmyalpineをpushする。pushする前に一度docker tagしてpush する
$ docker tag alpine:latest registry.octopt.com:443/myalpine $ docker push registry.octopt.com:443/myalpine The push refers to repository [registry.octopt.com:443/myalpine] 50644c29ef5a: Pushed latest: digest: sha256:a15790640a6690aa1730c38cf0a440e2aa44aaca9b0e8931a9f2b0d7cc90fd65 size: 528OK.
参考文献
- 投稿日:2020-07-20T18:22:59+09:00
Windowsのwsl2+docker試してみた
2020/07/19の備忘録
マイクロソフト公式の通りインストール
https://docs.microsoft.com/ja-jp/windows/wsl/install-win10
Windows Subsystem for Linux のインストール
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestartMicrosoft Store を開き、希望する Linux ディストリビューションをインストール。(今回は「Debian GNU/Linux」)
インストールしたディストリビューション起動&セットアップ。もしコンソール画面に「0x8007019e」エラーが発生したらPCを再起動
Installing, this may take a few minutes... WslRegisterDistribution failed with error: 0x8007019e The Windows Subsystem for Linux optional component is not enabled. Please enable it and try again. See https://aka.ms/wslinstall for details. Press any key to continue..."仮想マシン プラットフォーム" のオプション コンポーネントを有効にする
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestartWSL 2 を既定のバージョンとして設定する
# 現在のバージョンを確認 wsl -l -v wsl --set-default-version 2下記表示が出たら https://aka.ms/wsl2kernel に従って、WSL 2 で使用する Linux カーネルをコンピューターにインストール
WSL 2 を実行するには、カーネル コンポーネントの更新が必要です。詳細については https://aka.ms/wsl2kernel を参照してくださいリンク先でLinux カーネル更新プログラム パッケージをダウンロード&インストールする
再度確認
wsl --set-default-version 2 wsl --set-version Debian 2 wsl -l -vちなみにエクスプローラーのパスに
\\wsl$
を入力すると、インストールしたlinuxのディレクトリにアクセスできるwindowsにDockerインストール
公式からインストーラーDL
https://www.docker.com/products/docker-desktop「Enable WSL 2 Window Features」のチェックをして
インストールwsl2+Docker速度検証
- Windows10 MSI製デスクトップPC
- CPU:core i7-8700 3.2GHz 6コア 12スレッド
- メモリ:16GB
- シネベンチR20:1924
実運用しているPJのDockerビルド時間
→22分2秒
- MacBook Pro 15inc(2019)
- CPU: core i7 2.6GHz 6コア 12スレッド
- メモリ:32GB
- シネベンチR20:1547
実運用しているPJのDockerビルド時間
→20分14秒まとめ
Macbook Proの方が早いのはなぜ。。。メモリの差?
- 投稿日:2020-07-20T17:42:16+09:00
Dockerfileのスニペットのレビュー&Dockerfileベストプラクティスのまとめ
このチュートリアルでは、Alibaba Cloud上でのDockerfileの使用方法について実践的な経験を積むことに焦点を当てています。
本ブログは英語版からの翻訳です。オリジナルはこちらからご確認いただけます。一部機械翻訳を使用しております。翻訳の間違いがありましたら、ご指摘いただけると幸いです。
Alwyn Botha, Alibaba Cloud Tech Share Author. Tech Shareは、技術的な知識やベストプラクティスをクラウドコミュニティ内で共有することを奨励するAlibaba Cloudのインセンティブプログラムです。
このチュートリアルは、コピー&ペースト、シェル、実行するコマンドがないため、最初の3つのチュートリアルとは異なります。
このチュートリアルの手順に従うには、最新バージョンのDockerがインストールされているAlibaba Cloud Elastic Compute Serviceインスタンスにアクセスできることを確認してください。LinuxサーバにDockerをインストールする方法については、このチュートリアルを参照してください。
このチュートリアルは以下の部分で構成されています。
1、Dockerfilesのいくつかのスニペットのレビューは https://hub.docker.com にあります。
2、これらのスニペットからの洞察をまとめたデモDockerfileを構築します。
3、Dockerfileの用語集まとめテキスト
4、Dockerfileの成功事例まとめ
Dockerfilesのスニペットのレビューは順不同です。スニペットのいくつかは非常に基本的な見識しかないことに注意してください - 心配する必要はありません。それらの基本的な概念の多くを組み合わせると、質の高いDockerfileを作成することができます。
Dockerfilesのスニペット - EXPOSEのレビュー
# 7000: intra-node communication # 7001: TLS intra-node communication # 7199: JMX # 9042: CQL # 9160: thrift service EXPOSE 7000 7001 7199 9042 9160 CMD ["cassandra", "-f"]このスニペットはDockerfileの右下にあるものです。
他の人がやっているように、ランダムに散らばっているEXPOSE命令を見つけるためだけにDockerfile全体を読みに行く必要はありません。
ポート番号がきちんと番号順に並んでいます。ポート番号はすべて簡潔に書かれている。簡潔で完璧 - どのポートが何をするのかを一言で覚えておくだけでいい。
正確で完全 - #doclineのポート番号とEXPOSEの行のポート番号が一致しています。矛盾はありません。
あなたのEXPOSEはプロフェッショナルで初心者にも優しく見えなければなりません。
Cassandraとは何か?
https://en.wikipedia.org/wiki/Apache_Cassandra から参照
Apache Cassandraは、フリーでオープンソースの分散型ワイドカラムストア、NoSQLデータベース管理システムで、多くのコモディティサーバにまたがる大量のデータを処理するように設計されており、単一障害点のない高可用性を提供します。
Cassandraは、複数のデータセンターにまたがるクラスタに対して堅牢なサポートを提供し、非同期マスターレスレプリケーションにより、すべてのクライアントに対して低レイテンシの操作を可能にします。
Dockerfilesのスニペット - ユーザーIDのレビュー
# explicitly set user/group IDs RUN groupadd -r cassandra --gid=999 && useradd -r -g cassandra --uid=999 cassandra RUN groupadd -r sonarqube && useradd -r -g sonarqube sonarqubeNeo4jは拡張性が高く、堅牢なネイティブグラフデータベースです。
RUN addgroup -S neo4j && adduser -S -H -h /var/lib/neo4j -G neo4j neo4j他にもいくつかのDockerfileを見つけましたが、どれも同じようにしています:addgroupとadduserを全て一行にまとめています。
以下、私は2行に分割されるようにneo4jを変更しました:これがちょうど良いように見えます。
RUN addgroup -S neo4j \ && adduser -S -H -h /var/lib/neo4j -G neo4j neo4jDockerfilesのスニペットのレビュー - apt-get Install
ネクストクラウド:すべてのデータを安全に保管できます。ファイル、カレンダー、連絡先、メールなどにどのデバイスからでもアクセスし、共有することができます。
RUN set -ex; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ rsync \ bzip2 \ busybox-static \ ; \ rm -rf /var/lib/apt/lists/*; \私が見つけた中で一番読みやすかったapt-getの説明書です。
上のテキストと下の他の例を比較して、これがどのように優れているかを確認してください。
Apache Mavenは、ソフトウェアのプロジェクト管理と理解のためのツールです。
RUN apt-get update && \ apt-get install -y \ curl procps \ && rm -rf /var/lib/apt/lists/*一貫性のない、整列していないインデント。
Logstashは、イベントやログメッセージを収集、処理、転送するためのツールです。
# install plugin dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ apt-transport-https \ libzmq5 \ && rm -rf /var/lib/apt/lists/*apt-get update &&apt-get install は一行で全て完了します。Neo4j ( 下の20行) は1行に1つの命令しかありません。どれだけ簡単に読めるか見てください。
Javaは、並行型、クラスベース、オブジェクト指向の言語です。
RUN apt-get update && apt-get install -y --no-install-recommends \ bzip2 \ unzip \ xz-utils \ && rm -rf /var/lib/apt/lists/*apt-get update &&apt-get install は一行ですべて完了します。他には1行に1つの命令しかないものもあります。これがどれだけ簡単に読めるかは以下をご覧ください。
Neo4jは拡張性が高く、堅牢なネイティブグラフデータベースです。
RUN apk add --no-cache --quiet \ bash \ curl \ tini \ su-exec \ && curl --fail --silent --show-error --location --remote-name ${NEO4J_URI} \ && echo "${NEO4J_SHA256} ${NEO4J_TARBALL}" | sha256sum -csw - \ && tar --extract --file ${NEO4J_TARBALL} --directory /var/lib \ && mv /var/lib/neo4j-* /var/lib/neo4j \ && rm ${NEO4J_TARBALL} \ && mv /var/lib/neo4j/data /data \ && chown -R neo4j:neo4j /data \ && chmod -R 777 /data \ && chown -R neo4j:neo4j /var/lib/neo4j \ && chmod -R 777 /var/lib/neo4j \ && ln -s /data /var/lib/neo4j/data \ && apk del curl1行に1つの命令を完璧に並べるているので非常に読みやすいです。
インストールする apk パッケージの一覧をアルファベット順に表示します。
Curl は 6 行目で使用され、最後の行で削除されました。もう必要ないので削除しました。
NEO4J_TARBALL}を10行目で抽出し、12行目で削除しました。
Dockerfilesのスニペットのレビュー - iniファイル
ネクストクラウドとは?
+すべてのデータを安全に保管します。ファイル、カレンダー、連絡先、メールなど、あらゆるデバイスからお好きな条件でアクセスし、共有することができます。
RUN { \ echo 'opcache.enable=1'; \ echo 'opcache.enable_cli=1'; \ echo 'opcache.interned_strings_buffer=8'; \ echo 'opcache.max_accelerated_files=10000'; \ echo 'opcache.memory_consumption=128'; \ echo 'opcache.save_comments=1'; \ echo 'opcache.revalidate_freq=1'; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ \ echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ \ mkdir /var/www/data; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www/ pro 最初の 7 行目のエコー設定を opcache-recommended.ini に追加し、非常にすっきりしました。
すっきりとした空行で 4 つの異なる目的をきれいに区切っています。Dockerfiles のスニペットについてのレビュー
https://github.com/jenkinsci/docker/blob/587b2856cd225bb152c4abeeaaa24934c75aa460/Dockerfile
Jenkinsの継続的インテグレーションとデリバリーサーバ。
FROM openjdk:8-jdk RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/lists/* ARG user=jenkins ARG group=jenkins ARG uid=1000 ARG gid=1000 ARG http_port=8080 ARG agent_port=50000 ENV JENKINS_HOME /var/jenkins_home ENV JENKINS_SLAVE_AGENT_PORT ${agent_port} '# Jenkins is run with user `jenkins`, uid = 1000 '# If you bind mount a volume from the host or a data container, '# ensure you use the same uid RUN groupadd -g ${gid} ${group} \ && useradd -d "$JENKINS_HOME" -u ${uid} -g ${gid} -m -s /bin/bash ${user} '# for main web interface: EXPOSE ${http_port} '# will be used by attached slave agents: EXPOSE ${agent_port}プロの目線で見る:
1、ARGの名前はすべて小文字
2、関数でソートされた ARG 名: user + group; uid + guid; 2 ports
3、ENV はすべて大文字で名前を付ける。
4、2行でグループ追加とユーザー追加
5、useradd は groupadd と完全に一致。Dockerfilesのスニペット - RUNのレビュー
PostgreSQLオブジェクトリレーショナルデータベースシステム
ENV PATH $PATH:/usr/lib/postgresql/$PG_MAJOR/bin ENV PGDATA /var/lib/postgresql/data RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA" # this 777 will be replaced by 700 at runtime (allows semi-arbitrary "--user" values) VOLUME /var/lib/postgresql/dataロングランは他の行の間に挟まれて潰されています。
改良版:
RUN mkdir -p "$PGDATA" \ && chown -R postgres:postgres "$PGDATA" \ && chmod 777 "$PGDATA" \ # this 777 will be replaced by 700 at runtime (allows semi-arbitrary "--user" values)彼らのDockerfileの残りの部分は素晴らしいものです - 上のリンクを参照してください。彼らはまた、他のほとんどの人よりも多くのコメントを持っています。
Dockerfileのスニペットのレビュー - Sorted apt-get Install
https://hub.docker.com/_/httpd/ より
'# install httpd runtime dependencies '# https://httpd.apache.org/docs/2.4/install.html#requirements RUN apt-get update \ && apt-get install -y --no-install-recommends \ libapr1 \ libaprutil1 \ libaprutil1-ldap \ libapr1-dev \ libaprutil1-dev \ liblua5.2-0 \ libnghttp2-14=$NGHTTP2_VERSION \ libpcre++0 \ libssl1.0.0=$OPENSSL_VERSION \ libxml2 \ && rm -r /var/lib/apt/lists/*インストールするaptパッケージのリストをソートしました。
ソートされていない場合は以下のようになります。
RUN apt-get update && apt-get install -y --no-install-recommends \ libxml2 \ libaprutil1 \ libnghttp2-14=$NGHTTP2_VERSION \ libapr1-dev \ liblua5.2-0 \ libaprutil1-dev \ libpcre++0 \ libapr1 \ libssl1.0.0=$OPENSSL_VERSION \ libaprutil1-ldap \ && rm -r /var/lib/apt/lists/*手でソートする必要はありません。エディタには、リストをハイライト表示して「SORT」をクリックするだけの機能があるでしょう。
開発中であっても、特定の libapr を見つけるのに役立つように、このようなリストをソートしておくと便利です。今は、データを見落とさないように上から下まで注意深く読まなければなりません。このようなことが一度でも起こった場合、ワンクリックでSORTを行うのは時間の投資になります。
デモのDockerfileを構築する
良いDockerfileと悪いDockerfileがどのように見えるか見てきましたが、自慢できるDockerfileを作ってみましょう。
あなたのDockerfileは、以下の手順を少なくとも一度は使用しなければなりません。
あなたのDockerfileはクールな完成したアプリケーションである必要はありません。これらのコマンドで可能な構文や機能を試しているだけです。
コマンドを実行し、ファイルを追加し、ワークディレクトリを作成、環境変数と引数を追加します。いくつかのポートを公開し、すべてにラベルを付け、ENTRYPOINTを用意します。ここでの目的は、コマンドに慣れることです。
https://hub.docker.com/explore/ で見つけたテキストスニペットをコピーしてください。
入力として使うソフトが違えば違うほど、学習の過程が面白くなります。
FROM COPY ADD RUN LABEL EXPOSE ENVIRONMENT ENTRYPOINT VOLUME USER WORKDIR ARGDockerfileの概念
以下のテキストの目的は、あなたがどれだけDockerfileの用語を理解しているかをテストすることです。
このテキストにはDockerfileの概念を詰め込んだ文章が含まれています。
新しいことを教えるためのものではありません。
以下に書かれていることのほとんどを理解できれば、Dockerfileの用語に慣れていることになります。
以下の文章の約50%は以下からのものです。
https://docs.docker.com/glossary/
そのテキストは、より多くのDocker用語を含むように編集されました。
. . .
docker buildコマンドはDockerfileを使ってDockerイメージをビルドします。
Dockerfileは、Dockerイメージをビルドするために通常Linuxコマンドシェルで実行するすべてのLinuxコマンドを含むテキストファイルです。DockerはDockerfileから命令を読み取ることでイメージを構築することができます。
イメージは、分離されたコンテナ内でソフトウェアアプリケーションを実行するために必要なすべてのソフトウェアをレイヤー化したものです。イメージは実行されているわけではありません。
コンテナはdockerイメージのランタイムインスタンスです。イメージからコンテナを作成するには、docker runコマンドを使用することができます。
Dockerコンテナには、作成に使用したDockerイメージが含まれています。コンテナはミニ VM のようなものです。
Docker Hub - https://hub.docker.com - は、Docker イメージを保存するウェブサイトです。
レジストリとは、Dockerイメージのリポジトリが入っているWebサービスのことです。Docker Hubはレジストリです。
デフォルトのレジストリ - https://hub.docker.com - は、Docker Hubのブラウザを使ってアクセスするか、docker検索コマンドを使ってアクセスすることができます。
リポジトリはDockerイメージのセットです。リポジトリをレジストリサーバーにプッシュすることで、リポジトリを共有することができます - docker pushコマンドを使用します。この5つのチュートリアルのセットでは、このdocker pushコマンドは使いませんでした。
他にも1000人の人がdocker pushを使って1000枚のパブリックイメージを追加していました https://hub.docker.com
Dockerイメージはコンテナの基本です。イメージは、コンテナランタイム内で使用するためのルートファイルシステムの変更とそれに対応する実行パラメータのレイヤ化されたコレクションです。
docker runコマンドに追加の引数を指定せずにDockerfileを実行可能にしたい場合は、entrypoint、cmd、またはその両方を指定する必要があります。
名前付きボリュームとは、Dockerが管理しているボリュームのことです。
名前付きボリュームを作成する際には、フレンドリーなテキスト名を指定することができます。
匿名ボリュームは名前付きボリュームと似ていますが、匿名ボリュームの場合、時間の経過とともに同じボリュームを参照することが困難になることがあります。
Dockerfileベストプラクティスのまとめ
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
以下は、いくつかのDockerfileのベストプラクティスを一行でまとめたものです。
1、小さなビルドコンテキストを持つ... https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#understand-build-context
2、dockerignoreを使う ... https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#exclude-with-dockerignore
3、レイヤー数を最小化する... https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#minimize-the-number-of-layers
4、複数行の引数を並べ替え ... https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#sort-multi-line-arguments
5、アルパインFROMを使用... https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#from
6、ラベルを1枚追加 - 練習用に... https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#label
7、長くて複雑な RUN 文を複数行に分割する - 上記の例を参照してください ... https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run
8、任意のポートを公開する - 練習用に ... https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#expose
9、ENV変数の定義 ... https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#env
10、ADDとCOPYを使用して、その違いについて示す... https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#add-or-copy
11、ボリュームの定義 ... https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#volume
12、デモテストユーザーの追加 - このチュートリアルのトップに例あり ... https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user
13、作業ディレクトリの作成 ... https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#workdirフェーズ 1: 作成したデモDockerfileをレビューします。間違っていた点を修正します。
フェーズ 2: https://hub.docker.com/explore/ にアクセスします。
最初のパッケージ名: nginx をクリックしてください - そこにリストされている最初の Dockerfile を見つけてください - もう一度クリックして Dockerfile を確認してください。そして、それを簡単にスキャンして、ベストプラクティスが採用されているか、悪用されているかを確認してください。
また、上記で簡単に説明したきちんとしたプロスニペットも考慮してください。それらの Dockerfile を調べて、似たようなタイプの問題やベストプラクティスを見つけることができるかどうかを確認してください。
これを、時間のある限り多くの公式パッケージに対して行ってください。
また、そのウェブページの左上のボックスにお気に入りの Linux ソフトウェアの名前を入力してください。あなたの」ソフトウェアがどれだけうまくドッカー化されているかを調べてみてください。
あなたの番です。
この4つのチュートリアルで学んだことを職場で実践してみましょう。
これで、https://docs.docker.com/engine/reference/builder/ にある Dockerfile のリファレンスを読む準備ができました。
ここで述べられているほぼすべての概念に精通しているはずです。最初の3つのチュートリアルに基づいて、あなたはほとんどのDockerfileの説明を実際に実験してきました。
これで、非常に簡単に読めるようになったはずです。
今述べたことはすべて、以下のベストプラクティスにも同じように当てはまります。
https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/
これで、Alibaba Cloud Elastic Compute Service (ECS)インスタンス上でDockerコンテナを使ってクールなアプリを構築することができるようになりました。
アリババクラウドは日本に2つのデータセンターを有し、世界で60を超えるアベラビリティーゾーンを有するアジア太平洋地域No.1(2019ガートナー)のクラウドインフラ事業者です。
アリババクラウドの詳細は、こちらからご覧ください。
アリババクラウドジャパン公式ページ
- 投稿日:2020-07-20T17:09:41+09:00
Elastic BeanstalkでSSM ParameterStoreからパラメータ取得しようとして詰まったこと
経緯
- EBのマルチコンテナ環境って結局裏でECS動いてるだけだから、大体ECSの機能使えるだろと思ってた
- もともとEBの環境プロパティにDBの接続情報をぶち込んでいたが、平文であんまりよろしくないので、ParameterStoreに移そうと話が上がった。
- ECSでParameterStoreを利用したケースはあり、EBのMultiContainerは実質ECSで動作するがわかっていたため、タスク定義に指定すればおわりやろとおもっていた。
Dockerrun.aws.jsonで指定した場合
- EBのDockerrun.aws.jsonのContainerDifinissionのformatはECSとおなじとのことで、containerDefinitionsにsecretを追加して、EBのサービスRoleにParameterStoreを取得できるようポリシー設定した。
executionRoleArn
はECSタスク実行用のRole、ここを参考にIAMポリシーを付与したRolearnを設定- 結果的に
executionRoleArn
はDockerrun.aws.jsonでは無効なプロパティ扱いされ、executionRoleArn
を指定しろというECSのエラーが表示された。フォーマットが一緒のため検証時点ではエラーにならないが、適用されない模様。- ECSタスクの実行Roleは指定できず、最終的は別の方法をとった
Dockerrun.aws.json{ "AWSEBDockerrunVersion": 2, "executionRoleArn": "arn:aws:iam::aws_account_id:role/ecsTaskExecutionRole" "containerDefinitions": [ { "name": "api", "image": "xxxxxxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/eb-secret:latest", "essential": true, "memory": 128, "portMappings": [ { "hostPort": 80, "containerPort": 5000 } ], "environment": [], "secrets": [{ "name": "environment_variable_name", "valueFrom": "arn:aws:ssm:region:aws_account_id:parameter/parameter_name" }] } ] }entrypoint.shでコンテナの環境変数に展開する方法
― この方法ではコンテナ内にAWSCLI(とjq)を用意する必要がある
- 最終的にこの方法を利用したentrypoint.sh#!/bin/bash export AWS_DEFAULT_REGION = ap-northeast-1 export AWS_DEFAULT_OUTPUT = json export ENVIRONMENT_VARIABLE = $(aws ssm get-parameter --name parameter_name \ --with-decryption | jq -r '.Parameters[].Value')要約
- Elastic BeanstalkのMultiContainer環境ではコンテナ定義によってSSM ParameterStoreから取得したパラメータを環境変数に格納することはできないっぽい?
- ParameterStoreからDBの接続情報を取得するためには、コンテナ起動時にentorypoint.shでawscliを利用して、環境変数に格納する
- もしくは、アプリから直接SSM ParameterStoreに取りに行く必要がある
- 複数台一気にアプリを立ち上げるような場合はParameterStoreのスループット上限を気にするように。標準は40tps、引き上げは可能
- 投稿日:2020-07-20T16:47:53+09:00
【Docker】俺的にまとめた初学者向けDocker超基本コマンド(チートシート)
目次
- Dockerfileからイメージを作成
- コンテナを起動
- コンテナを停止
- イメージからコンテナを作成
- イメージの一覧を表示、イメージID確認
- イメージを削除
- コンテナの一覧を表示、コンテナID確認
- コンテナの削除
- 実行中のコンテナでコマンドを実行
概要
Docker初めて1週間の初心者Docker使いによる初心者のためのチートシートを作成しました。
コマンドがたくさんあり、どれから使ってみればいいのかわからない。
そもそも各コマンドはどんな動きをするの?といった方向けです。下記のチートシートのコマンドを使えるようになれば、Dockerをなんとか動かせるようになるのではないかと思います。
オプションの詳細等は公式ドキュメントのリンクを貼っているのでそちらを参照してください。
全コマンドの公式リファレンスはこちら=>公式リファレンス-コマンド一覧Dockerfileからイメージを作成
docker build [オプション] パス | URL | -【docker-build】公式リファレンス
例)docker build -t pythondev .
(カレントディレクトリ=Dockerfileが存在するディレクトリ)
- オプション(よく使うものを抜粋)
- -t, --tag=[] '名前:タグ' 形式で名前とオプションのタグを指定
- -f, --file="" Dockerfileの名前 (デフォルトは 'PATH/Dockerfile')
コンテナを起動
docker start コンテナIDコンテナを停止
docker stop コンテナIDイメージからコンテナを作成
docker run {イメージ名 | イメージID}
- オプション(よく使うものを抜粋)
- -it ホストとコンテナの標準入出力を接続
- -d バックグラウンドで実行
- -p 「ホストマシンのポート:コンテナのポート」でホスト側とコンテナを接続
- --name コンテナの名前を指定
イメージの一覧を表示、イメージID確認
docker images [オプション]
- オプション(よく使うものを抜粋)
- -a, --all=fa
イメージを削除
docker rmi [オプション] イメージID【docker-rmi】公式リファレンス
※コンテナが作成されている場合は削除できない。
- オプション(よく使うものを抜粋)
- -f, --force 強制削除
コンテナの一覧を表示、コンテナID確認
docker ps [オプション]
- オプション(よく使うものを抜粋)
- -l, --latest 最後に作成したコンテナを表示 (どのような状態でも)
- -a, --all 全てのコンテナを表示 (デフォルトは実行中コンテナのみ表示)
コンテナの削除
docker rm [オプション] コンテナID
- オプション(よく使うものを抜粋)
- -f, --force 実行中のコンテナを(SIGKILLを使い)強制的に削除
- -v, --volumes コンテナと関連づけられたボリュームを削除
実行中のコンテナでコマンドを実行
docker exec [オプション] コンテナID コマンド【docker-exec】公式リファレンス
※コンテナは起動中でないといけない。
例:起動中コンテナのbashを起動
exec -it {コンテナID} /bin/bash
- オプション(よく使うものを抜粋)
- -t, --tty=false 疑似ターミナル (pseudo-TTY) の割り当て
- -i, --interactive=false アタッチしていなくても STDIN をオープンにし続ける
- -u, --user= ユーザ名か UID (書式: <名前|uid>[:<グループ|gid>]
- 投稿日:2020-07-20T15:26:20+09:00
Dockerfileの使い方について
このチュートリアルでは、Alibaba Cloud上でのDockerfileの使用方法について実践的な経験を積むことに焦点を当てています。
本ブログは英語版からの翻訳です。オリジナルはこちらからご確認いただけます。一部機械翻訳を使用しております。翻訳の間違いがありましたら、ご指摘いただけると幸いです。
Dockerfile RUN
参考情報:https://docs.docker.com/engine/reference/builder/#run
RUNには2つの形式があります。
RUN (シェル形式。コマンドはシェルで実行され、デフォルトでは /bin/sh -c)
RUN "executeable", "param1", "param2"
RUN 命令は与えられた命令を実行し、その結果の出力を現在の画像の上に新しいレイヤーで作成します。
RUN は、おそらくイメージの最も大きな部分を作成するために使用されます。これは、サーバや vps を設定する際にシェルで使用するコマンドのほとんどを実行します。
例:
RUN mkdir ... RUN useradd .. RUN apt install ... RUN copy ... RUN unzip ...使用中のexecフォームとshellフォームを表示する簡単なDockerfileを作成してみましょう。
execフォームはコマンドshellを呼び出しません。つまり、通常のshell処理が行われないことを意味します。
nano Dockerfile内容です。
FROM alpine:3.8 RUN echo $HOME RUN ["echo", "$HOME”]実行してください。
docker build --no-cache --tag tutorial:demo --file Dockerfile .期待される出力
Sending build context to Docker daemon 258kB Step 1/3 : FROM alpine:3.8 ---> 196d12cf6ab1 Step 2/3 : RUN echo $HOME ---> Running in f9aed6be9bb4 /root Removing intermediate container f9aed6be9bb4 ---> dd939eaa9e43 Step 3/3 : RUN ["echo", "$HOME"] ---> Running in 38e244f781bc $HOME Removing intermediate container 38e244f781bc ---> 3872c058a5bc Successfully built 3872c058a5bc Successfully tagged tutorial:demoshell フォーム - ステップ 2 でシェル変数の置換が行われることに注意してください。
exec フォーム - ステップ 3 でシェル変数の置換が行われないことに注意してください。
Dockerfile CMD
https://docs.docker.com/engine/reference/builder/#cmd
CMD と ENTRYPOINT の命令は、それらに特化した長いチュートリアルに値するものです。
ここでの演習は、これらのコマンドの5%の基本的な導入に過ぎません。
あなたのコンテナは、他の人にソフトウェアサービスを提供するために存在しています。CMD と ENTRYPOINT は、コンテナの起動時にどのようなソフトウェアを実行するかを定義する方法です。Linux の機能の全体像は広大です。残念ながら、CMD と ENTRYPOINT は、あらゆるユースケースを可能にするために、無限に強力な (いじれる) ものでなければならないことを意味しています。
この一連のDockerfileチュートリアルを終えた後に、https://hub.docker.com/explore/ にアクセスすることをお勧めします。ダウンロードされた上位10個のイメージのURLにアクセスしてください。一番上に掲載されているDockerfileをクリックしてください。CMDとENTRYPOINTの使い方を勉強してください。これがあなたをDockerfileのエキスパートにしてくれるものです:他の簡単なDockerfileの説明書の組み合わせではなく、CMDとENTRYPOINTの洞察力に富んだ使い方です。
エキスパートボーナスの洞察と加速された学習のために、これらのイメージをすべてダウンロードして、開発サーバーで実行してください。また、docker runを使用する場合は、CMDとENTRYPOINTをオーバーライドします。
アリババは、https://www.alibabacloud.com/product?spm=a3c0i.7911826.1160486.82.7d90737b0qnGmg で利用可能なクラウドサービスソフトウェアの広大なセットを持っています。
それらをどのように付加価値のある方法でマージし、組み合わせ、接続するかで成功が決まります。CMDとENTRYPOINTはDockerコンテナでソフトウェアを公開する方法です。
ここでは、私の一日目(一行のDockerfile)の初心者向けのエクササイズを紹介します。
残念ながらDockerfileにはCMD命令は一つしかありません。そのため、いくつかの小さなDockerfileを使ってCMDの違いをデモする必要があります。
https://docs.docker.com/engine/reference/builder/#cmd より
CMD 命令には 3 つの形式があります。
1、CMD "executable"、"param1"、"param2 "
2、CMD "param1", "param2”
3、CMD コマンド param1 param2 (シェル形式)https://docs.docker.com/engine/reference/builder/#cmd より
exec フォームは JSON 配列として解析されるので、単語の周りにはシングルクォート (') ではなくダブルクォート (") を使用しなければなりません。
nano Dockerfile
FROM alpine:3.8 CMD ["/bin/echo", "hello from CMD - using exec form”]実行します。
docker build --tag tutorial:demo --file Dockerfile . docker run --name tutorial tutorial:demo期待される出力
hello from CMD - using exec form今度はシェルフォームを使ってCMDします。
FROM alpine:3.8 CMD /bin/echo "hello from CMD using shell form”実行します。
docker build --tag tutorial:demo --file Dockerfile . docker stop -t 0 tutorial ; docker container prune -f;docker ps -a docker run --name tutorial tutorial:demo期待される出力は以下の通りです。
hello from CMD using shell formexec フォームはコマンドシェルを呼び出しません - つまり、シェル変数の置換はありません。
シェル処理機能が必要な場合は、shellフォームを使用してください。
CMD /bin/echo $HOME は あなたの $HOME ディレクトリを表示します。
CMD [ "echo", "$HOME" ] を実行すると、$HOME ディレクトリは表示されませんが、$HOME はそのまま表示されます。
ここでは、shellフォームを使って$HOMEの内容を表示してみましょう。
実行してみましょう。
nano Dockerfileこのテキストを入力してください
FROM alpine:3.8 CMD /bin/echo $HOME実行します。
docker build --tag tutorial:demo --file Dockerfile . docker stop -t 0 tutorial ; docker container prune -f;docker ps -a docker run --name tutorial tutorial:demo期待される出力。
/rootLinux shellでは、** /bin/echo $HOME **を使って$HOMEの値を表示します。DockerfileでCMD命令のshell構文を使うのと全く同じように動作します。
以下のようにしてイメージを実行していることに注意してください。
docker run --name tutorial tutorial:demoCMD命令はイメージの実行時に実行するコマンドを定義します。dockerでの実行では、実行するコマンドを指定していません。CMD は、この場合 echo が実行されなければならないことを定義しています。
RUN 命令はイメージをビルドするために使用します。これはビルド時に実行されます。
CMD命令はビルド時には何も実行しませんが、docker run時に実行するコマンドを指定します。
Dockerfileで定義されているCMDをオーバーライドすることができます。これを行うには、イメージの実行時に実行するコマンドを指定します。例えば、
docker stop -t 0 tutorial ; docker container prune -f;docker ps -a docker run -ti -d --name tutorial tutorial:demo /bin/sh -c 'echo ECHO text from run command'期待される出力 .
ECHO text from run commandなお、DockerfileのCMDからのエコーは実行されません。docker runコマンドからのエコーテキストのみが表示されます。
Dockerfile ENTRYPOINT
https://docs.docker.com/engine/reference/builder/#entrypoint より
ENTRYPOINTには2つの形式があります。
1、ENTRYPOINT "executable"、"param1"、"param2 "です。
2、ENTRYPOINTコマンド param1 param2 (シェル形式)
ENTRYPOINTでは、実行ファイルとして実行するコンテナを設定することができます。例えば、以下のようにすると、デフォルトの内容でnginxが起動し、ポート80でリッスンされます。
docker run -i -t --rm -p 80:80 nginx
残念ながら、彼らが与えた例は間違っています: https://github.com/nginxinc/docker-nginx/blob/a22b9f46fe3a586b02d974f64441a4c07215dc5d/mainline/stretch/Dockerfile の公式 nginx Dockerfile には ENTRYPOINT がありません。
nginxのDockerfileの最後の行は
CMD ["nginx", "-g", "daemon off;"]
ということで、前に表示されたdocker runを実行すると、CMDはnginxを実行しますが、その特定のDockerfileにはENTRYPOINTがありません。
紛らわしいですね。
では、実際のENTRYPOINT命令を含むミニDockerfileを作成してみましょう。まずはシェルのフォームから。
FROM alpine:3.8 ENTRYPOINT /bin/echo ECHO from ENTRYPOINT - shell form実行します。
docker build --tag tutorial:demo --file Dockerfile . docker stop -t 0 tutorial ; docker container prune -f;docker ps -a docker run --rm --name tutorial tutorial:demo毎回実行後にコンテナを停止して剪定するのが面倒になってきました。
上記の --rm オプションを使用したことに注意してください。これで終了したコンテナが自動的に削除されます。
rm がどのように動作するかを確認するには、もう一度 docker を実行してください。
docker run --rm --name tutorial tutorial:demo期待される出力。
ECHO from ENTRYPOINT - shell formまた
docker run --rm --name tutorial tutorial:demo同じ出力です。終了したコンテナをクリーンアップ/プルーニングする必要はありません。とても便利ですね。
ENTRYPOINTの実行形式の例。
nano Dockerfile
FROM alpine:3.8 ENTRYPOINT ["/bin/echo", "ECHO from ENTRYPOINT - exec form"]実行します。
docker build --tag tutorial:demo --file Dockerfile . docker run --rm --name tutorial tutorial:demo期待される出力 .
ECHO from ENTRYPOINT - exec formDockerfile VOLUME
https://docs.docker.com/engine/reference/builder/#volume より
VOLUME命令は、指定された名前のマウントポイントを作成し、ネイティブホストや他のコンテナから外部マウントされたボリュームを保持していることをマークします。
全くその通りです。VOLUME 命令は、指定された名前のマウント ポイントを作成します。
紛らわしいこと: ネイティブホストまたは他のコンテナから外部マウントされたボリュームを保持しているとマークされます。
これは外部マウントされたボリュームを保持しません - コンテナの内部に新しいボリュームを作成します。
Linuxにおけるボリュームという用語は、論理ボリュームマネージャ(LVM)に関連しています - VOLUME命令はそのような外部ボリュームをマウントしません。
ネイティブホストまたは他のコンテナ88からの外部マウントされたボリュームを保持するようにそれをマークします。 VOLUME命令には他のコンテナはありません。
VOLUME命令はマウントポイントを作成し、それはDockerが管理する/var/lib/docker/volumes/にディレクトリを作成します。
準備:開発サーバーにボリュームがない場合や少ない場合に役立つでしょう。そこで、このコマンドを実行して、現在のボリュームのリストを確認してください。
docker volume listリストが短ければ短いほど、これから作成するボリュームを見やすく、見つけやすくなります。私のリストは空なので、このチュートリアルでは任意の時点で存在するボリュームの完全なリストを表示します。
Dockerの公式ドキュメントにあるDockerfileを使って、何が起こるか見てみましょう。
nano Dockerfile
FROM alpine:3.8 RUN mkdir /myvol RUN echo "hello world" > /myvol/greeting VOLUME /myvol実行します。
docker build --tag tutorial:demo --file Dockerfile . docker stop -t 0 tutorial ; docker container prune -f;docker ps -a docker run --rm -ti -d --name tutorial tutorial:demo /bin/sh -c 'while true; do sleep 60; done' docker exec -it tutorial /bin/shls コマンドを入力します - myvol がコンテナ内に存在することを確認します。
cat myvol/greeting と入力します。
期待される出力 .
hello worldコンテナを終了します。
docker run コマンドは、新しく作成されたボリューム /myvol を、ベースイメージ内の指定された場所 (グリーティングファイル) に存在する任意のデータで初期化します。
myvol という名前は、このコンテナ内にのみ存在します。この名前は他のコンテナでは使用できません。
このDockerfileの結果、docker runが/myvolに新しいマウントポイントを作成し、グリーティングファイルを新しく作成されたボリュームにコピーするイメージになります。
myvolはコンテナ内でのみボリュームの名前とマウントポイントになります。
他のコンテナが myvol 名 / マウントポイントを参照することはできません。
重要: お使いのコンピュータで生成されたボリューム名は異なります。このチュートリアルに従うときは、あなたのボリューム名を使用してください。
docker volume list期待される出力 .
DRIVER VOLUME NAME local de82d92daf539b7147770877704ed438b053c50744e874e7a6b86655cd50cf44実行します。
docker volume inspect de82d92daf539b7147770877704ed438b053c50744e874e7a6b86655cd50cf44期待される出力 .
[ { "CreatedAt": "2018-10-23T15:19:14+02:00", "Driver": "local", "Labels": null, "Mountpoint": "/var/lib/docker/volumes/de82d92daf539b7147770877704ed438b053c50744e874e7a6b86655cd50cf44/_data", "Name": "de82d92daf539b7147770877704ed438b053c50744e874e7a6b86655cd50cf44", "Options": null, "Scope": "local" } ]データがあるマウントポイントをメモしておきます。
ls /var/lib/docker/volumes/de82d92daf539b7147770877704ed438b053c50744e874e7a6b86655cd50cf44/_data/グリーティングファイルを表示しています。
今、このコンテナを停止すると(--rmで実行されているので)、コンテナが削除されたときに、Dockerはコンテナに関連付けられた匿名のボリュームも削除します。
そうすると、
docker stop -t 0 tutorial ; docker container prune -f;docker ps -a docker volume listボリュームがなくなっていることに気づくでしょう。
anon ボリュームの詳細
再び /myvol でコンテナを実行してみましょう。
docker run -ti -d --name tutorial tutorial:demo /bin/sh -c 'while true; do sleep 60; done'docker ボリュームリストには anon ボリューム - ランダムなボリューム名が表示されているはずです。
他にもanonボリューム/myvolを使って3つのAlpineコンテナを起動してみましょう。
docker run -d --name alpine1 -v /myvol alpine:3.8 /bin/sh -c 'while true; do sleep 60; done' docker run -d --name alpine2 -v /myvol alpine:3.8 /bin/sh -c 'while true; do sleep 60; done' docker run -d --name alpine3 -v /myvol alpine:3.8 /bin/sh -c 'while true; do sleep 60; done'実行します。
docker volume listもう一度。
Expected output : DRIVER VOLUME NAME local 0a43eb2703d4a1638e1a466a9cbae5aba1071939a3b047dc7c27d383b83cebea local 8edd9ff9f14a6038df3013ea7b581aeda41e6045584b6c350ba4b20e60e6f6a2 local b02d0f7b3c5be418718b1732be0e46c735806b22791dd70fa44036bb2ffa520e local f5a2bb741141616255333c54c421926a8a06ac59f5b054e4619a1dfef4da2fbc4 つのコンテナにはそれぞれ /myvol という名前の自分のボリュームがあります。
ここで実行します。
docker stop -t 0 tutorial docker stop -t 0 alpine1 docker stop -t 0 alpine2 docker stop -t 0 alpine3このチュートリアルでは、anonのボリュームのみを使用しています。
実行します。
docker container prune -f;docker ps -aは4つのコンテナが削除されたことを示しています。
実行します。
docker volume list4つのボリュームがすべて残っていることを示します。
これらのボリュームを削除するには
docker volume pruneプロンプトでyを答える。
期待される出力 .
WARNING! This will remove all local volumes not used by at least one container. Are you sure you want to continue? [y/N] y Deleted Volumes: 51742ef4c728f01870e49edcf29ffa0407eee3363c21fd90493a9c786b36f430 0670752370af7bc92e4fbf1ce513dc8b5472169c4d7e8023e6dc207c510a023f 0c797c8a480e12c450870a78a3cc3de3c22e483162882e1972ed399148e3c00e 0e36fa721df75a9bbcf16fbe2aa809845aee016f7f00c2c6bebefbc27b2832c0 Total reclaimed space: 11Bここで学んだ教訓。
1、AnonボリュームはDockerfileのVOLを使って作成されます。
2、Anonボリュームはコンテナを実行しているときに-volumeを使って作成することもできます。
3、Anonボリュームはコンテナの外では友好的な名前はありません。
4、コンテナの実行時に --rm を指定すると、Anon ボリュームは自動的に削除されます。
5、docker volume prune を使用して、少なくとも 1 つのコンテナで使用されていないすべてのボリュームを削除してください。名前付きボリュームはコンテナの外に作成され、名前を付けて一つずつ意図的に削除しなければなりません。名前付きボリュームは長期的なデータのために使用します。
名前付きボリュームはコンテナの数に制限なくマウントして共有することができます。
Dockerボリュームは膨大なトピックです - 詳しくは https://docs.docker.com/storage/volumes/ をご覧ください。
このチュートリアルでは、DockerfileでVOLを使って作成されるanon / anonymousボリュームについて簡単に紹介しました。
anonボリュームの名前を変更する方法はありません - おそらくこれからもありません - https://github.com/moby/moby/issues/31154 を参照してください。
きれいな名前のボリュームが欲しい場合は、名前付きボリュームが必要になります。
他のコンテナがこのボリュームを使用したい場合は、長い無名の名前を使用しなければなりません。明らかにこの醜い長い名前は理想的ではないので、コンテナの外に 名前付きボリュームを作成するのが好ましい方法です。そうすれば、すべてのコンテナはこの簡単で記述的なボリューム名を使うことができます。
Dockerfile LABEL
https://docs.docker.com/engine/reference/builder/#label
画像には無制限にラベルを付けることができます。これらのラベルは画像を説明するために使用できます。
また、ラベルを使って特定のラベルを持つ画像だけを選択的にフィルタリングすることもできます。それでは実際に見てみましょう。
nano Dockerfile入力:
FROM alpine:3.8 LABEL version="demo label" LABEL description="This text illustrates \ that label values can span multiple lines." CMD echo "container with labels”実行します。
docker build --tag tutorial:demo --file Dockerfile .イメージのすべてのラベルを表示するには、次のように実行します。
docker inspect tutorial:demoそのコマンドからスニペット出力を抽出しました。
"Labels": { "description": "This text illustrates that label values can span multiple lines.", "version": "demo label" }また、実行します。
docker images --filter "label=version=demo label”期待される出力 .
REPOSITORY TAG IMAGE ID CREATED SIZE tutorial demo 16d6a13eb022 3 minutes ago 4.41MBそのデモラベルが付いたイメージだけが表示されました。
docker images コマンドにはラベル欄がないことに注意してください。
(--format) オプションを指定した docker images コマンドにもラベルを印刷する機能はありません。
https://docs.docker.com/engine/reference/commandline/images/#format-the-output
公式Dockerハブ https://hub.docker.com にある公式イメージでラベルを使用しているものはほとんどありません。
しかし、すべての画像に膨大なメタ情報(ラベル)の構造を作成することができます。画像を選択したり分類したりする唯一の方法は、画像が持つことのできる単一のタグを使用することです。
Dockerfile ARG
https://docs.docker.com/engine/reference/builder/#arg より
ARG 命令は、ユーザがビルド時に --build-arg = フラグを使って docker ビルドコマンドでビルダーに渡すことができる変数を定義します。
ARG 命令を定義する際にデフォルト値を含めることができます。
引数は通常、ユーザー名、ディレクトリ名、ソフトウェアパッケージのバージョン番号などをビルド時に渡すために使われます。
簡単なDockerfileを作成して、実際にARGが使われているのを見てみましょう。
nano Dockerfileこれを入力してください。
FROM alpine:3.8 ARG target_dir=dir1 WORKDIR /root/${target_dir} RUN pwd RUN echo ${target_dir} COPY gamefile /root/${target_dir} COPY anothergame /root/${target_dir}実行します。
docker build --tag tutorial:demo --file Dockerfile .期待される出力 .
Sending build context to Docker daemon 258kB Step 1/7 : FROM alpine:3.8 ---> 196d12cf6ab1 Step 2/7 : ** ARG target_dir=dir1 88 ---> Running in 15ef296ddf95 Removing intermediate container 15ef296ddf95 ---> fe6be5de15bb Step 3/7 : ** WORKDIR /root/${target_dir} 88 ---> Running in a64dbe343a98 Removing intermediate container a64dbe343a98 ---> e41509ae6f7b Step 4/7 : ** RUN pwd 88 ---> Running in 3b886f0637b4 88 /root/dir1 88WORKDIR /root/${target_dir}が${target_dir}をdir1に置き換えることに注意してください。 ステップ7 RUN pwdは.../root/dir1を示しています。
Removing intermediate container 3b886f0637b4 ---> 08468a2fec81 Step 5/7 : ** RUN echo ${target_dir} 88 ---> Running in a6a8a8be8252 88 dir1 88 Removing intermediate container a6a8a8be8252 ---> 48a9ffe90e28 Step 6/7 : COPY gamefile /root/${target_dir} as ---> a09e827ec1c7 Step 7/7 : COPY anothergame /root/${target_dir} ---> d14edc1f440d Successfully built d14edc1f440d Successfully tagged tutorial:demoステップ5 RUN echo ${target_dir}はdir1も表示します。
ステップ6とステップ7では、${target_dir}も同様にdir1に置換されていると考えてよいでしょう。
プログラムを書いている人ならば、変数の置換がどのように行われるか知っているでしょう。ARGも全く同じように動作します。
ARGはビルド時にのみ存在します。環境変数ではありません。bash シェルで PRINTENV を実行しても ARG は表示されません。
これでパート3の4は終了です:Dockerfileのインストラクションをすべて知ってください。もっと詳しく知りたい方はパート4を読んでください。
アリババクラウドは日本に2つのデータセンターを有し、世界で60を超えるアベラビリティーゾーンを有するアジア太平洋地域No.1(2019ガートナー)のクラウドインフラ事業者です。
アリババクラウドの詳細は、こちらからご覧ください。
アリババクラウドジャパン公式ページ
- 投稿日:2020-07-20T15:02:50+09:00
【WordPress】docker-composeを使ってWordPress開発環境をたった3分で構築する
はじめに
【この記事は5分で読了できます】
docker-composeを使ってWordPressの開発環境をたった3分で爆速構築します。
(まだpullされていないimageをpullする時間は除きます。)今回はDockerの公式ドキュメント(英語)を参考に進めますので、英語のドキュメントが読める方はそちらをご参考ください。
動作確認環境
- macOS Catalina (ver. 10.15.5)
- Docker Desktop for Mac (ver. 2.3.0.3)
手順
実際にやっていきましょう!
1. ディレクトリの作成
新しくディレクトリを作成します。
今回は[my_wordpress]という名前にしました。mkdir my_wordpress cd my_wordpress/
2. docker-compose.ymlの作成
先ほど作ったディレクトリ直下にdocker-compose.ymlファイルを作ります。
touch docker-compose.yml
docker-compose.ymlに以下の内容を記述します。
docker-compose.ymlversion: '3.3' services: db: image: mysql:5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: - db image: wordpress:latest ports: - "8000:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress WORDPRESS_DB_NAME: wordpress volumes: db_data: {}ビルド
docker-composeでビルドします。
detachedモードで起動する-d
オプションをつけています。docker-compose up -d
WordPressの起動
ブラウザでWordPressを起動します。
Docker Desktop for Mac (or Windows)の場合、http://localhost:8000にアクセスします。言語選択
アクセスすると以下の画面になります。
お好きな言語を選択してください。(日本語もあります。)
フォーム入力
次に以下の画面になります。
必要な情報をフォームに入力し、Install WordPressをクリックします。
WordPress開発環境構築
無事WordPress開発環境が構築できました!やったー!
終了コマンド
以下のコマンドで終了できます。
docker-compose down
コンテナとデフォルトのネットワークを削除しますが、WordPressのデータベースはそのまま保持されます。
docker-compose down --volumes
コンテナとデフォルトのネットワークを削除し、WordPressのデータベースも削除します。参考サイト
- 投稿日:2020-07-20T12:08:15+09:00
Dockerfile:LinuxサーバにDockerをインストールする
このチュートリアルでは、Alibaba Cloud上でのDockerfileの使用方法について実践的な経験を積むことに焦点を当てています。
本ブログは英語版からの翻訳です。オリジナルはこちらからご確認いただけます。一部機械翻訳を使用しております。翻訳の間違いがありましたら、ご指摘いただけると幸いです。
Dockerfile HEALTHCHECK
このセクションでは、DockerfileでのHEALTHCHECKの使い方を説明します。
HEALTHCHECKは、指定したスケジュールでコンテナの健全性を自動チェックします。
HEALTHCHECK [OPTIONS] CMDコマンド
CMDの前に表示されるオプションは、以下の通りです。
--interval=DURATION (default: 30s) --timeout=DURATION (default: 30s) --start-period=DURATION (default: 0s) --retries=N (default: 3)このチュートリアルでは、これらの時間は非常に長いです。すぐにテストして、チェックが機能するのを確認したいのです。
これをDockerfileに追加するには
nano Dockerfile
FROM alpine:3.8 HEALTHCHECK --interval=3s --timeout=1s \ CMD curl -f http://localhost/ || exit 1重要: この特定の Alpine コンテナでは、curl -f http://localhost/ health check コマンドは常に失敗することに注意してください。
イメージをビルドするには
docker build --tag tutorial:demo --file Dockerfile .コンテナを起動して結果を見てみましょう。
docker stop -t 0 tutorial ; docker container prune -f docker run -ti -d --name tutorial tutorial:demo /bin/sh -c 'while true; do sleep 60; done’コンテナが起動したら、docker ps -aを1秒ごとに(10秒間)繰り返し実行して、ヘルスチェックの進行状況を確認します。
docker ps -a期待される出力。
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 27134771d5dd tutorial:demo "/bin/sh -c 'while t�" 3 seconds ago Up 1 second (health: starting)10秒後に以下のようになります。
docker ps -a期待される出力。
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 27134771d5dd tutorial:demo "/bin/sh -c 'while t�" 12 seconds ago Up 10 seconds (unhealthy) tutorial(health:starting)は10秒間表示されますが、チェックは3秒間隔で行われるので ( --interval=3s)、 --timeout=1sを指定しています。
この間隔を1秒に短縮して、より早くヘルスの結果を表示できるようにしましょう。
また、リトライ回数をデフォルトの3回から1回に減らしてみましょう。--retries=1
PROD環境ではretries = 1を使うことはほぼないでしょう。3の方がはるかに現実的な値です。
これをDockerfileに追加するには
nano Dockerfile
FROM alpine:3.8 HEALTHCHECK --interval=1s --timeout=1s --retries=1 \ CMD curl -f http://localhost/ || exit 1を使用して画像を構築します。
docker build --tag tutorial:demo --file Dockerfile .コンテナを起動して結果を見てみましょう。
docker stop -t 0 tutorial ; docker container prune -f docker run -ti -d --name tutorial tutorial:demo /bin/sh -c 'while true; do sleep 60; done';docker ps -a; sleep .4; docker ps -a; sleep .4; docker ps -a; sleep .4; docker ps -a; sleep .4;コンテナの状態を 0.4 秒ごとにチェックしていることに注意してください。
期待される出力。
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1e83c476c2ee tutorial:demo "/bin/sh -c 'while t�" 1 second ago Up Less than a second (health: starting) tutorialCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1e83c476c2ee tutorial:demo "/bin/sh -c 'while t�" 2 seconds ago Up Less than a second (health: starting) tutorialCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1e83c476c2ee tutorial:demo "/bin/sh -c 'while t�" 2 seconds ago Up 1 second (unhealthy) tutorialCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1e83c476c2ee tutorial:demo "/bin/sh -c 'while t�" 3 seconds ago Up 1 second (unhealthy) tutorial0.8秒の間、健康状態は(ヘルス:開始)です。
1秒後にステータスが(異常)に変わります。
実際のprod環境に合わせてこれらの設定をいじるのは管理者であるあなた次第です。
--interval=DURATION (default: 30s) --timeout=DURATION (default: 30s) --start-period=DURATION (default: 0s) --retries=N (default: 3)管理者としても、適切なヘルスチェックコマンドを prod env で決定しなければなりません。Webサーバコンテナ、データベースコンテナ、ハプロキシコンテナは、すべて異なるヘルスチェックの要件を持っています。
ここでは、状態がどのように変化するかを素早く表示するために使用しています。
健康状態がどのように見えるかを確認するために、成功するヘルスチェックのサンプルを実行してみましょう。
これをDockerfileに追加するには
nano Dockerfile
FROM alpine:3.8 HEALTHCHECK --interval=.1s --timeout=.4s --retries=1\ CMD sleep .1 || exit 1を使用して画像を構築します。
docker build --tag tutorial:demo --file Dockerfile .コンテナを起動して結果を見てみましょう。
docker stop -t 0 tutorial ; docker container prune -f docker run -ti -d --name tutorial tutorial:demo /bin/sh -c 'while true; do sleep 60; done';docker ps -a; sleep .4; docker ps -a; sleep .4; docker ps -a; sleep .4; docker ps -a; sleep .4;期待される出力。
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c83552f66511 tutorial:demo "/bin/sh -c 'while t�" 1 second ago Up Less than a second (health: starting) tutorialCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c83552f66511 tutorial:demo "/bin/sh -c 'while t�" 2 seconds ago Up Less than a second (healthy) tutorialCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c83552f66511 tutorial:demo "/bin/sh -c 'while t�" 2 seconds ago Up 1 second (healthy) tutorialCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c83552f66511 tutorial:demo "/bin/sh -c 'while t�" 3 seconds ago Up 2 seconds (healthy) tutorialsleep .1 は 10 分の 1 秒間正常にスリープし、その後ステータスのリターンコードを返します。
残念ながら、docker ps -a コマンドのステータスフィルタは健康状態によるコンテナのマッチングを行いません。フィルタリングできるのは、created, restarting, running, removing, paused, exited, dead のみです。
実行できません: docker ps --filter status=healthy
実行できません: docker ps --filter status=unhealthy
以下の
docker ps -a | grep '(healthy)'
そして
docker ps -a | grep '(unhealthy)'
を使う必要があります。Dockerfile EXPOSE Ports
このセクションでは、Dockerfile が EXPOSE を使ってコンテナのポートを公開する方法を学びます。
コンテナは孤立した実行プロセスです。コンテナは、他のコンテナがアクセスできるポートを明示的に指定しなければなりません。
ポートとは、プロセスが他のプロセスに連絡してコマンドを送信するための公式な方法です。
例えば、Apache のポート 80 は通常公開されています。Apache はコンテナの中に隔離されて隠れています。何かをさせる唯一の方法は、ポート 80 を通してアクセスすることです。
EXPOSE 命令はコンテナが listen するポートを宣言します。
ポートがTCPかUDPかを指定することができます。プロトコルが指定されていなければデフォルトはTCPです。
EXPOSE 命令は実際にポートを公開しません。
EXPOSE はドキュメントとしての役割を果たすだけです。これは、コンテナ内のどのポートが公開可能な状態にすることを意図しているかを宣言します。
https://docs.docker.com/engine/reference/builder/#expose より
コンテナの実行時に実際にポートを公開するには、docker run で -p フラグを使用して 1 つ以上のポートを公開してマッピングするか、-p フラグを使用してすべての公開されたポートを公開して高次ポートにマッピングします。
デフォルトでは、expose は TCP を想定しています。UDP を指定することもできます。
EXPOSE 80/tcp
EXPOSE 80/UDP
このチュートリアルでは、ポート80、tcpとudpを公開します。
Dockerfileを以下のように編集します。
nano Dockerfile
FROM alpine:3.8 EXPOSE 80/tcp EXPOSE 80/udpを使用して画像を構築します。
docker build --tag tutorial:demo --file Dockerfile .コンテナを起動して結果を見てみましょう。
docker run -ti -d --name tutorial tutorial:demo /bin/sh -c 'while true; do sleep 60; done'期待される出力
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6269a988e1dd tutorial:demo "/bin/sh -c 'while t�" 1 second ago Up Less than a second (health: starting) 80/tcp, 80/udp tutorialports カラムには、公開されているポートが表示されていますが、使用できません。それらを公開しなければなりません。docker runコマンドの-p 30000:80/tcpを使って公開します。
-p 30000:80/tcp
30000 はホストのポート番号を指定します。80/tcpはコンテナのポート番号を指定します。
コンテナを作成して結果を見てみましょう。
docker stop -t 0 tutorial; ; docker container prune -f docker run -p 30000:80/tcp -ti -d --name tutorial tutorial:demo /bin/sh -c '\''while true; do sleep 60; done'\'''期待される出力。
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8b3e43916708 tutorial:demo "/bin/sh -c 'while t�" 1 second ago Up Less than a second 0.0.0.0:30000->80/tcp, 80/udp tutorial0.0.0.0.0:30000->80/tcp
localhost のポート 30000 はコンテナのポート 80 にマップされています。
これでホスト上でポート30000が開いていることが確認できます。
ss コマンドはソケットに関する情報を表示するために使用されます。ss コマンドはソケットの情報を表示するために使用します。( netstatコマンドはCentOSのデフォルトインストールでは存在しなくなりました。代わりに service コマンドを使用します。)
ss -t -a -nオプションの短いバージョン、長いバージョン。
1、-t, --tcp は TCP ソケットのみを表示します。
2、-a, --all すべてのソケットを表示します。
3、-n, --numeric はサービス名を解決しないので、ポート番号を数値で表示します。期待される出力
State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* ESTAB 0 0 192.168.56.44:22 192.168.56.11:4118 ESTAB 0 64 192.168.56.44:22 192.168.56.11:2719 LISTEN 0 128 :::30000 :::* LISTEN 0 128 :::22 :::*30000番ポートがホストでリッスンされていることがわかります。
30000には特別な意味はありません。ここでは簡単に見つけられるポート番号として使われているだけです。
同様に udp 80 番ポートも公開してみましょう。実行してみてください。
docker stop -t 0 tutorial; ; docker container prune -f docker run -p 40080:80/udp 30000:80/tcp -パブリッシュがうまくいったかどうかを確認します。
ss -u -a -n期待される出力
State Recv-Q Send-Q Local Address:Port Peer Address:Port UNCONN 0 0 :::40080 :::*今回は -u 引数を使って udp ポートを表示していることに気がつきました。
Dockerfile の ENV 変数
環境変数を使用して、実行中のコンテナに値を送ることができます。
環境変数はコンテナが動作する環境の一部です。
構文は以下の通りです。構文:
ENVENV =
ENV 命令は、環境変数に値を設定します。
例えば
ENV myVar1=1 ENV myVar42=42 ENV myAlfaVar=alfa value abc私たちの小さなAlpine Linuxディストロを使って、env内のenv変数を見てみましょう。
この内容でDockerfileを作成します。
FROM alpine:3.8 ENV myVar1 1 ENV my42 42 ENV myVar42=42 ENV myAlfaVar='alfa abc'env変数の宣言には2種類の方法を使っていることに注意してください。
画像をビルドするには
docker build --tag tutorial:demo --file Dockerfile .実行:
docker stop -t 0 tutorial ; docker container prune -f docker run -ti -d --name tutorial tutorial:demo /bin/sh -c 'while true; do sleep 60; done' docker exec -it tutorial /bin/sh#(プロンプト)でprintenvコマンドを入力します。
期待される出力
/ # printenv HOSTNAME=1314796592cf SHLVL=1 HOME=/root my42=42 TERM=xterm myVar1=1 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin myAlfaVar=alfa abc myVar42=42 PWD=/ / # exit宣言したenv変数はすべてそこにあります。
docker runを使うときにenv変数をオーバーライドすることができます。
実行:
docker stop -t 0 tutorial ; docker container prune -f docker run -e 'my42=44000' -ti -d --name tutorial tutorial:demo /bin/sh -c 'while true; do sleep 60; done'今コンテナに入るとmy42が44000になっているのがわかります。
docker exec -it tutorial /bin/sh期待される出力
/ # printenv HOSTNAME=1190753a779e SHLVL=1 HOME=/root my42=44000 TERM=xterm myVar1=1 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin myAlfaVar=alfa abc myVar42=42 PWD=/これで、DockerfileでENV変数を宣言したり、docker run -e 'my-env-var-name=new value'を使ってENV変数をオーバーライドしたりする実践的な経験ができるようになりました。
また、printenv を使って env 変数の内容を調べることもできます。(シェルプロンプトで env 変数を表示するには set や env を使うこともできます)
詳細は https://en.wikipedia.org/wiki/Environment_variable
https://docs.docker.com/engine/reference/builder/#env
https://docs.docker.com/engine/reference/builder/#environment-replacement
これで4のパート2は終了です: すべてのDockerfileのインストラクションを知ることができます。もっと詳しく知りたい方は、パート3を読んでください。
アリババクラウドは日本に2つのデータセンターを有し、世界で60を超えるアベラビリティーゾーンを有するアジア太平洋地域No.1(2019ガートナー)のクラウドインフラ事業者です。
アリババクラウドの詳細は、こちらからご覧ください。
アリババクラウドジャパン公式ページ
- 投稿日:2020-07-20T11:03:35+09:00
【Rails】docker-composeの速度を上げる方法
開発環境
・Docker: 19.03.8
・Docker-Compose: 1.25.5
・Ruby: 2.5.7
・Rails: 5.2.4
・Vagrant: 2.2.7
・VirtualBox: 6.1
・OS: macOS Catalina前提
下記実装済み。
原因
docker-compose実行時に、
temp
、log
、vendor
、.git
等の余計なファイルをマウントしてしまっている。解決方法
マウントする必要のないディレクトリのマウントを、別のvolumeで上書きします。
docker-compose.yml
を編集docker-compose.yml# 変更前 version: '3' services: db: image: postgres volumes: - ./tmp/db:/var/lib/postgresql/data environment: POSTGRES_PASSWORD: password web: build: . command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" volumes: - .:/myapp ports: - "3000:3000" depends_on: - db # 変更後 version: '3' services: db: image: postgres volumes: - ./tmp/db:/var/lib/postgresql/data environment: - POSTGRES_HOST_AUTH_METHOD=trust web: build: . command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" volumes: - .:/app:cached - /app/vendor - /app/tmp - /app/log - /app/.git ports: - '3000:3000' depends_on: - db
- 投稿日:2020-07-20T03:13:25+09:00
DockerとGoで簡単にapiサーバーを立ててみる
はじめる前に
こんにちはRIN1208です
この記事はDockerとGoを少し触れている程度の学生が書いていますので分からない点、間違っている点等がございましたらコメントして頂けると幸いです。
今回の書いたDockerfileなどはこちらに置いてあります。この記事の対象
- Dockerについてなんとなく知っている人
- Goを知っている人
- とりあえず両方触ってみたい人
この記事で触れない事
- Dockerがどのように動いているか
- Dockerの環境構築について
- Docker Hubの詳細について
- Dockerとは何か
- Goのコードの詳細について
- マルチステージビルド
開発環境
- macOS Catalina
- Go(ver 1.14.4)こちらはなくても問題ありません
- Docker(後半でDocker-composeも使用します)
- VSCode(お好みのエディターを使用して下さい) 上記の環境で説明していきます
さわってみる
今回やる事
- コンテナの起動などの基本動作
- Dockerfileを書く
- Goで簡単なWebサーバーを立てる
今回触れない事
- Docker Networkを使用したコンテナ間通信
Nginxをdockerで起動してみる
下記のコマンドを実行してみましょう
docker run --name hoge -d -p 8080:80 nginx起動後に
http://localhost:8080/
に接続するとWelcome to nginx!と表示されます。今入力したコマンドの説明
docker run: コンテナを起動するコマンドです
--name: 起動するコンテナに名前をつけられます。今回はhogeという名前です
-d: このオプションを使用するとバックグラウンドで起動することができます
-p: ポートのオプションですホストのポート:コンテナのポート
で指定できます。今回はホストが8080、コンテナが80で起動しています。起動したコンテナの確認
下記のコマンドを実行してみましょう
docker psすると以下のように表示されると思います
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 63940a31eae8 nginx "/docker-entrypoint.…" 3 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp hoge表示項目の説明
CONTAINER ID: コンテナのIDです。コンテナを指定する際に使用します
IMAGE: 使用したDockerimageです。今回はnginxを使用したのでnginxになっています
COMMAND: コンテナが起動する際に与らたコマンドです
CREATED: コンテナを作成してからの時間です
STATUS: 起動、停止してからの経過時間です
PORTS: コンテナ及びホストの使用ポート
NAMES: コンテナの名前です。こちらの名前を使用してコンテナを指定することもできます起動したコンテナの停止
下記のコマンドを実行してみましょう
docker stop hoge実行するとコンテナが停止しました。
docker ps
で確認してみましょうCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESとだけ表示されます。こちらの項目に先ほど確認したコンテナが存在しなければコンテナの停止ができています。
またdocker ps
コマンドは起動しているコンテナを確認するコマンドなので他にも起動しているコンテナがある場合は表示されますDockerfileを書いてコンテナを作成する
次はDockerfileを書いてGoのapiサーバーを立ち上げてみましょう。
今回はGoのwebフレームワークであるGinを使用します。今回触れない事
- マルチステージビルド
- Go Modules
Dockerfileとmain.goを作成する
適当な同じディレクトリに内にDockerfileとmain.goを作成しましょう。
main.gopackage main import ( "github.com/gin-gonic/gin" ) func main() { r := gin.Default() r.GET("/", hoge) r.Run() // デフォルトが8080ポートなので今回は変更しません } func hoge(c *gin.Context) { c.JSON(200, "hogeeeeeeee") }dockerfile
FROM golang:1.14 RUN go get -u github.com/gin-gonic/gin WORKDIR /app COPY . /app ENV CGO_ENABLED=0 \ GOOS=linux \ GOARCH=amd64 EXPOSE 8080 CMD ["go", "run", "main.go"]設定項目の説明
FROM : 実行する環境を指定します。DockerHubにあるimageをしますので使用する際はDockerHubにあるかどうか確認してください。バージョン指定がない場合は最新バージョン(latest)が使用されます。
RUN : コマンドを実行します
WORKDIR : 作業ディレクトリを設定します
COPY : コンテナにディレクトリ、ファイルるをコピーします。
ENV : コンテナに永続的な環境変数を定義します。
コピーする対象 コンテナ内のコピー先
で指定できますEXPOSE : コンテナの使用ポートを指定します
CMD : 実行するコンテナにコマンドと引数を提供します
Dockerfileからimageを作成し起動する。
以下のコマンドでbuildしimageを作成します。Dockerfileのあるディレクトリ内で実行しましょう。
今回はmy-imageという名前のimageを作成し起動します。docker build -t my-image .buildが完了しましたら下記のコマンドを実行しREPOSITORYの項目にmy-imageという名前があるのを確認しましょう。
docker images下記のようにREPOSITORYの項目にmy-imageとあれば問題ありません。
REPOSITORY TAG IMAGE ID CREATED SIZE my-image latest b498e18e4087 6 hours ago 956MB確認することができましたら以下のコマンドでコンテナを起動させましょう。
今回は先ほど作成したimageのmy-imageを使用しmy-apiという名前のコンテナを作成しています。docker run -it --name my-api my-image今回は-dオプションをつけていないのでバックグラウンドで動作させていませんが-dオプションを指定すればバックグラウンドで動かすことができます。
docker run -d -it --name my-api my-image上記のコマンドでapiサーバーが起動できたのを確認できます。
今回はhttp://localhost:8080/
にて立ち上がっています。docker-composeを使ってみる
次は先ほど立ち上げたコンテナをdocker-composeで立ち上げます。
Mysql等との接続は記事が長くなるのに加え、少しややこしいので今回は触りません。docker-compose.yml
version: "3" services: api: # コンテナの名前 build: . # dockerfileの場所を指定できます。 ports: - "8080:8080" tty: trueコンテナのビルド
下記のコマンドでビルドします。
ymlファイルを書き換えた際はbuildしないと反映されません。ちょくちょく忘れてやらかしますdocker-compose buildコンテナの起動
下記のコマンドでコンテナを立ち上げます。 今回は -d オプションを使用しバックグラウンドにて立ち上げています
docker-compose up -d起動できましたら
http://localhost:8080/
にて確認してみましょう。起動したコンテナの確認
立ち上がっているコンテナは下記のコマンドにて確認することができます。
docker-compose psすると以下のように表示されると思います。
Name Command State Ports ------------------------------------------------------------------- docker-test_api_1 go run main.go Up 0.0.0.0:8080->8080/tcpName : コンテナの名前
Command : コンテナが起動する際に与らたコマンドです
State : コンテナのステータスです
Ports : コンテナ及びホストの使用ポートです起動したコンテナの停止
下記のコマンドでコンテナを停止させることができます。
docker-compose down終わりに
ここまで読んでくださりありがとうございます。
この記事は友人のDockerの勉強のためになればと思い書きました。また初めてDocker触る方の手助けになれば幸いです。
間違っている点などがございましたらコメントなどで指摘していただけると助かります。
- 投稿日:2020-07-20T00:11:00+09:00
【三日目】最小限の構成でdocker-composeからKubernetesにデプロイする勉強会
概要
表題の勉強会を行った三日目の内容を記載します。全日の内容は以下のまとめページをご覧ください。
【まとめ】最小限の構成でdocker-composeからKubernetesにデプロイする勉強会
三日目のできたこと
- テスト用のコンテナイメージの作成
- CI/CD pipelinesにテストを組み込む
三日目の内容
テスト用のコンテナイメージの作成
簡単なテストを実行するコンテナを作成します。
python
を使ってリクエスト送り、その結果を判別します。具体的に処理を説明する、リクエストに返ってきた内容でぷよぷよ
という文字列が含まれていればsys.exit(0)
で正常終了。逆に含まれてなければsys.exit(1)
で異常終了になります。これは後のGitLab CI/CD
につながります。import os import requests import sys url = os.getenv('URL', 'http://localhost:3000') check_str = os.getenv('CHECK_STR', 'ぷよぷよ') try: r_get = requests.get(url) response = True if r_get.ok else r_get.reason print(r_get.text) if r_get.text.find(check_str) == -1: print(check_str + "ではないので問題です!!") sys.exit(1) else: print(check_str + "なので大丈夫です。") sys.exit(0) except requests.exceptions.RequestException as e: response = str(e) sys.exit(1)pythonだけでテストを試す
このテストはローカルの
python
でも実行できます。予めローカルのpython
の環境で、requests
はImport
しておく必要があります。以下の手順でテストを実行できます。
- Pythonをインストール
requests
がない場合はpip install requests
docker-compose
でapp
をup
しておく
- 一番上のフォルダに移動
docker-compose up -d app
http://localhost:3000
でアクセスできることを確認- ローカルの
python
でテストを実行
python test/test.py
docker-compose.ymlにtestを追加
まずはコンテナを作るために
Dockerfile
を準備します。alpine
にはrequests
は含まれていないのでインストールしています。■ Dockerfile
FROM python:3.6-alpine WORKDIR /app COPY ./*.py /app/ RUN pip install requests CMD ["python", "test.py" ]この
Dockerfile
を元にdocker-compose.yml
でtestのサービスを追加します。■ docker-compose.yml
version: '3' services: app: build: context: ./app # Dockerfile保存場所 image: registry.gitlab.com/tamoco-mocomoco/k8s-test/express:latest ports: # ポート接続 - 3000:5000 environment: PORT: 5000 test: build: context: ./test environment: URL: http://app:5000 CHECK_STR: "ぷよぷよ"環境変数で接続先のURLやチェックする文字列を上書きしています。ここで注目すべきはコンテナの中から接続するため、
app
だったりポートがアプリ内のポート番号である5000
になっている点です。先ほどのローカルのpython
で実行した場合は、docker-compose
で転送された後のURLやポート番号にアクセスしていましたが、コンテナの中から接続するところを意識することが重要になります。docker-comopseでテストを実行する(テスト用コンテナで実行)
docker-compose でコンテナを作成してテストすることができます。
■ コンテナでテストを実行する(成功)
$ docker-compose run test <!DOCTYPE html> <html> <head> <title>ぷよぷよワダオ</title> <link rel='stylesheet' href='/stylesheets/style.css' /> </head> <body> <h1>ぷよぷよワダオ</h1> <p>Welcome to ぷよぷよワダオ</p> </body> </html> ぷよぷよなので大丈夫です。コンテナで実行する場合は、元のソースが変更した場合は
build
しなおす必要があります。ここらへんはホットリロード(自動的にコンテナ内のソースを更新する仕組み)などの機能を追加した方がよさそうです。ちなみにテストを失敗させたい場合は
app/express/routes/index.js
のぷよぷよ
という文字列をむきむき
などに変更すると失敗します。■ コンテナでテストを実行する(失敗)
$ docker-compose run test <!DOCTYPE html> <html> <head> <title>むきむきワダオ</title> <link rel='stylesheet' href='/stylesheets/style.css' /> </head> <body> <h1>むきむきワダオ</h1> <p>Welcome to むきむきワダオ</p> </body> </html> ぷよぷよではないので問題です!!CI/CD pipelinesにテストを組み込む
.gitlab-ci.yml
にテスト用のコンテナでテストする仕組みを追加します。テストがパスすればコンテナイメージをbuild
するようにしました。■ .gitlab-ci.yml
image: docker:latest stages: - test - build variables: DOCKER_DRIVER: overlay services: - docker:dind before_script: - docker info - apk update - apk upgrade - apk add docker-compose - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker-compose build test: stage: test script: - docker-compose up -d app - sleep 5s - docker-compose run test build: stage: build script: - docker-compose pushPipelineを確認する
以下の画像のとおりテストが実行されていることが確認できました。
成功した場合は以下のような実行結果が確認できます。
失敗した場合は以下のような実行結果が確認できます。
三日目を振り返って
当初はシェルスクリプトで
curl
を実行して結果を判別するカンタンなテストを準備していました。apk add curl
を実行してCI上のコンテナにcurl
を追加してテストする仕組みを想定していましたが、若干ハマってしまったのでpython
で小さく作ることにしました。実際にテスト用のコンテナを作る場合は、
cypress
などのe2e
のテストを実行できるコンテナを使うのがよいと思います。
- 投稿日:2020-07-20T00:10:52+09:00
【二日目】最小限の構成でdocker-composeからKubernetesにデプロイする勉強会
概要
表題の勉強会を行った二日目の内容を記載します。全日の内容は以下のまとめページをご覧ください。
【まとめ】最小限の構成でdocker-composeからKubernetesにデプロイする勉強会
二日目のできたこと
- GitLabのCI/CD pipelinesによるContainer RegistryへのPush
二日目の内容
pipelines
でビルド及びプッシュするに.gitlab-ci.yml
を作成しました。ここでのポイントは以下のとおりです。
docker-compose
はdocker:dind
に入っていないため追加する$CI_REGISTRY_USER
などで予めdocker login
しておく■ .gitlab-ci.yml
image: docker:latest stages: - test - build variables: DOCKER_DRIVER: overlay services: - docker:dind before_script: - docker info - apk update - apk upgrade - apk add docker-compose - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker-compose build build: stage: build script: - docker-compose push
.gitlab-ci.yml
によってPackages & Registries
の
Container Registry
にコンテナイメージが作成されていることが確認できます。二日目を振り返って
.gitlab-ci.yml
についてはdocker
のサンプルがあり、それを元に作成しました。CI/CD
のPipelines
で成功・失敗が一目でわかるので、トライ&エラーを重ねながら無事に作成することができました。今回は小規模の.gitlab-ci.yml
の作成になるので、実際にプッシュして動作確認していますが、実際はGitLab Runnerのコンテナを用いて動作検証した方がよかったりします。
- 投稿日:2020-07-20T00:10:45+09:00
【一日目】最小限の構成でdocker-composeからKubernetesにデプロイする勉強会
概要
表題の勉強会を行った一日目の内容を記載します。全日の内容は以下のまとめページをご覧ください。
【まとめ】最小限の構成でdocker-composeからKubernetesにデプロイする勉強会
一日目のできたこと
- Node.js(Express)のアプリケーションの作成
- Dockerfileの作成
- docker-compose.ymlの作成
一日目の内容
カンタンにNode.jsでアプリケーションを作成しました。
それらをコンテナで動作するようにDockerfileを作成しました。
WORKDIRでカレント及びフォルダを作成し、そのフォルダに対してexpress
配下のファイルをコピーしています。■ Dockerfile
# ベースイメージを指定 FROM node:14.5-alpine3.12 # 環境変数設定 ENV NODE_ENV="development" # 作業ディレクトリ作成&設定 WORKDIR /src COPY ./express /src RUN npm install CMD npm run startそして最後に
Dockerfile
をdocker-comopse
でも動作させるようにしました。
GitLab
のContainer Registry
にプッシュするためにimage
を設定しlatest
というタグも設定しています。本当はプッシュするときにイメージ名やタグを設定した方がよいのですが、今回は決め打ちでimage
に設定しています。■ docker-compose.yml
version: '3' services: app: build: context: ./app # Dockerfile保存場所 image: registry.gitlab.com/tamoco-mocomoco/k8s-test/express:latest ports: # ポート接続 - 3000:3000一日目を振り返って
Express
はサンプルがたくさんあるので手早くできました。Dockerfile
からdocker-compose
も慣れれば難しくなくbuild
とcontext
さえ注意すれば大丈夫でした。悩んだところとしてはフォルダの構成で少しフォルダを整理したりしました。今回の場合はExpress以外にもアプリケーションが増えたことを考えて
app
配下にExpress
という構成にしています。もし他のアプリケーションが増えた場合は
app
配下に別のフォルダを作成して別にDockerfile
を作成することで構成がわかりやすくなると思っています。複数のアプリケーションになった時点でDockerfile
自体のファイル名もアプリケーションごとに変えたり、docker-compose.yml
もcontext
のDockerfile
を指定する必要が出てくると思います。この辺については拡張する機会があった場合に、また記事として投稿させていただければ幸いです。
- 投稿日:2020-07-20T00:10:39+09:00
【まとめ】最小限の構成でdocker-composeからKubernetesにデプロイする勉強会
概要
docker-compose
で作った最小構成のアプリケーションを元にKubernetes
にデプロイすることを目的に勉強会を行いました。平日のお仕事が終わったあとの1時間くらいを毎日続けて目的が達成できましたので、レポートとして残しておきます。本来は一日一記事を投稿予定でしたが、平日のお仕事の都合もあるため、投稿までは即座に断念し後で投稿することにしました。一日ごとに記事として投稿し、このページはまとめページとして記載させていただきます。
目標
- 最小限の構成で
docker-compose
からアプリケーションを作成するGitLab
のCI/CD
を使ってみる- テストコードを作りテストする仕組みを
CI/CD
に組み込むdocker-compose
のイメージからKubernetes
で動作させてみるなぜ開催したか?
以前に「やりたいことを実現するためのワークショップ」を開催しました。そこで興味あることとして「仮想化」が優先してやりたいことに挙がったため、今回その取っ掛かりになるような勉強会を開催いたしました。
全日通してできたこと
- Node.js(Express)のアプリケーションの作成
- Dockerfileの作成
- docker-compose.ymlの作成
- GitLabのCI/CD pipelinesによるContainer RegistryへのPush
- テスト用のコンテナイメージの作成
- CI/CD pipelinesにテストを組み込む
- Kubernetes
- deployment.ymlの作成
- service.ymlの作成
- Kubernetes
- GitLabでDeployTokenの作成
- secretの作成
成果物
https://gitlab.com/tamoco-mocomoco/k8s-test/
全体を通して振り返り
平日の夜間の一時間程度の時間を使って少しずつ理解を深めていきました。もちろんスムーズに行かなかったところもありましたが、ハマったところも含めて勉強になったと思います。
ただ一日一時間だけとはいえ、それなりに目標を達成できたかなと。ちゃんと時間を作ってやることが大切なんだなと思います。
Kubernetes
については、まだまだ理解できていないことも多く、もっと深く学習を深める必要があると感じました。この勉強会で終わらせず
AWS EKS
へのデプロイや、データベースを作成してKubernetes
でpvc
を使ったり、それらをどうやってAWS
のサービスと連携させるのか進めていければと思います。