LoginSignup
1
0

More than 5 years have passed since last update.

CWL User Guide 7: Running Tools Inside Docker をやってみた

Last updated at Posted at 2017-12-06

CWL User Guide 7: Running Tools Inside Docker

Common Workflow Language User Guide: Running Tools Inside Docker

今回は Docker を利用した例について書かれています
docker コンテナを使って javascript を実行します。

この回にでてくる主なキーワード

  • Docker
  • Dockerrequirements
  • hints

CWLファイル、docker.cwl

docker.cwl
#!/usr/bin/env cwl-runner

cwlVersion: v1.0
class: CommandLineTool
baseCommand: node
hints:
  DockerRequirement:
    dockerPull: node:slim
inputs:
  src:
    type: File
    inputBinding:
      position: 1
outputs: []

パラメータファイル docker-job.yml

docker-job.yml
src:
  class: File
  path: hello.js

必要なファイル

Javascriptのファイルを実行する必要があります

echo "console.log(\"Hello World\");" > hello.js

実行

実行方法

cwltool docker.cwl docker-job.yml

実行結果

$ cwltool docker.cwl docker-job.yml
/usr/local/bin/cwltool 1.0.20171107133715
Resolved 'docker.cwl' to 'file:///home/vagrant/cwl_user_guide_work/07-containers/docker.cwl'
['docker', 'pull', 'node:slim']
slim: Pulling from library/node
85b1f47fba49: Pull complete
ba6bd283713a: Pull complete
b9968e24de01: Pull complete
838ee1f471db: Pull complete
0aeceafac5a9: Pull complete
ac225a9df894: Pull complete
Digest: sha256:be3ec422193a582d802d2948149d502c421f34749fd4535295e6538e3cd39dc8
Status: Downloaded newer image for node:slim
[job docker.cwl] /tmp/tmp_zLyzf$ docker \
    run \
    -i \
    --volume=/tmp/tmp_zLyzf:/var/spool/cwl:rw \
    --volume=/tmp/tmpfQ5mMZ:/tmp:rw \
    --volume=/home/vagrant/cwl_user_guide_work/07-containers/hello.js:/var/lib/cwl/stg93732819-d8a8-449c-b8ea-1ca6f684464b/hello.js:ro \
    --workdir=/var/spool/cwl \
    --read-only=true \
    --user=1000:1000 \
    --rm \
    --env=TMPDIR=/tmp \
    --env=HOME=/var/spool/cwl \
    node:slim \
    node \
    /var/lib/cwl/stg93732819-d8a8-449c-b8ea-1ca6f684464b/hello.js
Hello World
[job docker.cwl] completed success
{}
Final process status is success

実行結果すこし細く

前半部分で、dockerが 'node:slim' とってきていることがわかります。
2度目に実行するときは、すでにコンテナが存在するので、この部分がなくなります。

実行結果確認

実行結果の最後から4行目で Hello World がじっこうされていることがわかります

Hello World

さらにちょっと

hello.js のメッセージを少し変更して、ふたたび実行してみましょう。
出力がかわることを確認できるとおもいます。

今回使ったファイル

cwl_user_guide_work/07-containers at master · manabuishii/cwl_user_guide_work

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0