Merge branch '8784-dir-listings'
[arvados.git] / doc / user / topics / arv-docker.html.textile.liquid
index 2bf4b8f40513ec62e77a9e3d497b4d8c47301654..1a78025b2570fef3db597ef88cb900072ae519b2 100644 (file)
@@ -1,27 +1,36 @@
 ---
 layout: default
 navsection: userguide
-title: "Customizing the Crunch runtime environment"
+title: "Customizing Crunch environment using Docker"
 ...
+{% comment %}
+Copyright (C) The Arvados Authors. All rights reserved.
 
-This page describes how to customize the runtime environment (e.g. the programs, libraries, and other dependencies needed to run a job) that a crunch script will be run in using "Docker.":https://www.docker.com/
+SPDX-License-Identifier: CC-BY-SA-3.0
+{% endcomment %}
 
-This page will demonstrate:
+This page describes how to customize the runtime environment (e.g., the programs, libraries, and other dependencies needed to run a job) that a crunch script will be run in using "Docker.":https://www.docker.com/  Docker is a tool for building and running containers that isolate applications from other applications running on the same node.  For detailed information about Docker, see the "Docker User Guide.":https://docs.docker.com/userguide/
 
-# How to fetch the arvados/jobs Docker image
+This page will demonstrate how to:
+
+# Fetch the arvados/jobs Docker image
 # Manually install additional software into the container
 # Create a new custom image
-# Upload that image to Arvados for use by Crunch jobs.
+# Upload that image to Arvados for use by Crunch jobs
+# Share your image with others
+
+{% include 'tutorial_expectations_workstation' %}
 
+You also need ensure that "Docker is installed,":https://docs.docker.com/installation/ the Docker daemon is running, and you have permission to access Docker.  You can test this by running @docker version@.  If you receive a permission denied error, your user account may need to be added to the @docker@ group.  If you have root access, you can add yourself to the @docker@ group using @$ sudo addgroup $USER docker@ then log out and log back in again; otherwise consult your local sysadmin.
 
-{% include 'tutorial_expectations' %}
+h2. Fetch a starting image
 
-h2. Fetching a starting image
+The easiest way to begin is to start from the "arvados/jobs" image which already has the Arvados SDK installed along with other configuration required for use with Crunch.
 
-First, download the latest image from the Docker registry:
+Download the latest "arvados/jobs" image from the Docker registry:
 
 <notextile>
-<pre><code>$ <span class="userinput">docker pull arvados/jobs</span>
+<pre><code>$ <span class="userinput">docker pull arvados/jobs:latest</span>
 Pulling repository arvados/jobs
 3132168f2acb: Download complete
 a42b7f2c59b6: Download complete
@@ -41,37 +50,33 @@ c7fd77eedb96: Download complete
 </code></pre>
 </notextile>
 
-h2. Installing new packages
+h2. Install new packages
 
-Next, enter the container using "docker run", the arvados/jobs image, and the program you want to run (in this case the bash shell).
+Next, enter the container using @docker run@, providing the arvados/jobs image and the program you want to run (in this case the bash shell).
 
 <notextile>
 <pre><code>$ <span class="userinput">docker run --interactive --tty --user root arvados/jobs /bin/bash</span>
-root@a0e8299b59aa:/#
+root@fbf1d0f529d5:/#
 </code></pre>
 </notextile>
 
 Next, update the package list using @apt-get update@.
 
 <notextile>
-<pre><code>root@a0e8299b59aa:/# <span class="userinput">apt-get update</span>
-Get:1 http://apt.arvados.org wheezy Release.gpg [490 B]
-Get:2 http://apt.arvados.org wheezy Release [1568 B]
-Get:3 http://apt.arvados.org wheezy/main amd64 Packages [34.6 kB]
-Get:4 http://ftp.us.debian.org wheezy Release.gpg [1655 B]
-Get:5 http://ftp.us.debian.org wheezy-updates Release.gpg [836 B]
-Get:6 http://ftp.us.debian.org wheezy Release [168 kB]
-Ign http://apt.arvados.org wheezy/main Translation-en
-Get:7 http://security.debian.org wheezy/updates Release.gpg [836 B]
-Get:8 http://security.debian.org wheezy/updates Release [102 kB]
-Get:9 http://ftp.us.debian.org wheezy-updates Release [124 kB]
-Get:10 http://ftp.us.debian.org wheezy/main amd64 Packages [5841 kB]
-Get:11 http://security.debian.org wheezy/updates/main amd64 Packages [218 kB]
-Get:12 http://security.debian.org wheezy/updates/main Translation-en [123 kB]
-Hit http://ftp.us.debian.org wheezy/main Translation-en
-Hit http://ftp.us.debian.org wheezy-updates/main amd64 Packages/DiffIndex
-Hit http://ftp.us.debian.org wheezy-updates/main Translation-en/DiffIndex
-Fetched 6617 kB in 5s (1209 kB/s)
+<pre><code>root@fbf1d0f529d5:/# apt-get update
+Hit http://security.debian.org jessie/updates InRelease
+Ign http://httpredir.debian.org jessie InRelease
+Ign http://apt.arvados.org jessie InRelease
+Hit http://apt.arvados.org jessie Release.gpg
+Get:1 http://security.debian.org jessie/updates/main amd64 Packages [431 kB]
+Hit http://apt.arvados.org jessie Release
+Hit http://httpredir.debian.org jessie-updates InRelease
+Get:2 http://apt.arvados.org jessie/main amd64 Packages [257 kB]
+Get:3 http://httpredir.debian.org jessie-updates/main amd64 Packages [17.6 kB]
+Hit http://httpredir.debian.org jessie Release.gpg
+Hit http://httpredir.debian.org jessie Release
+Get:4 http://httpredir.debian.org jessie/main amd64 Packages [9049 kB]
+Fetched 9755 kB in 2s (3894 kB/s)
 Reading package lists... Done
 </code></pre>
 </notextile>
@@ -79,45 +84,57 @@ Reading package lists... Done
 In this example, we will install the "R" statistical language Debian package "r-base-core".  Use @apt-get install@:
 
 <notextile>
-<pre><code>root@a0e8299b59aa:/# <span class="userinput">apt-get install r-base-core</span>
+<pre><code>root@fbf1d0f529d5:/# <span class="userinput">apt-get install r-base-core</span>
 Reading package lists... Done
 Building dependency tree
 Reading state information... Done
 The following extra packages will be installed:
   [...]
-libxv1 libxxf86dga1 libxxf86vm1 r-base-core r-base-dev r-base-html r-cran-boot r-cran-class r-cran-cluster r-cran-codetools
+  libxxf86vm1 make patch r-base-core r-base-dev r-cran-boot r-cran-class
+  r-cran-cluster r-cran-codetools r-cran-foreign r-cran-kernsmooth
+  r-cran-lattice r-cran-mass r-cran-matrix r-cran-mgcv r-cran-nlme r-cran-nnet
+  r-cran-rpart r-cran-spatial r-cran-survival r-doc-html r-recommended
   [...]
 Suggested packages:
   [...]
 The following NEW packages will be installed:
   [...]
-  libxv1 libxxf86dga1 libxxf86vm1 r-base r-base-core r-base-dev r-base-html r-cran-boot r-cran-class r-cran-cluster
+  libxxf86vm1 make patch r-base-core r-base-dev r-cran-boot r-cran-class
+  r-cran-cluster r-cran-codetools r-cran-foreign r-cran-kernsmooth
+  r-cran-lattice r-cran-mass r-cran-matrix r-cran-mgcv r-cran-nlme r-cran-nnet
+  r-cran-rpart r-cran-spatial r-cran-survival r-doc-html r-recommended
   [...]
-0 upgraded, 107 newly installed, 0 to remove and 9 not upgraded.
-Need to get 88.2 MB of archives.
-After this operation, 219 MB of additional disk space will be used.
+0 upgraded, 203 newly installed, 0 to remove and 39 not upgraded.
+Need to get 124 MB of archives.
+After this operation, 334 MB of additional disk space will be used.
 Do you want to continue [Y/n]? y
 [...]
-Get:85 http://ftp.us.debian.org/debian/ wheezy/main r-base-core amd64 2.15.1-4 [20.6 MB]
-Get:86 http://ftp.us.debian.org/debian/ wheezy/main r-base-dev all 2.15.1-4 [3882 B]
-Get:87 http://ftp.us.debian.org/debian/ wheezy/main r-cran-boot all 1.3-5-1 [472 kB]
+Get:130 http://httpredir.debian.org/debian/ jessie/main r-cran-cluster amd64 1.15.3-1 [475 kB]
+Get:131 http://httpredir.debian.org/debian/ jessie/main r-base-dev all 3.1.1-1 [4018 B]
+Get:132 http://httpredir.debian.org/debian/ jessie/main r-cran-boot all 1.3-13-1 [571 kB]
+Get:133 http://httpredir.debian.org/debian/ jessie/main r-cran-codetools all 0.2-9-1 [45.7 kB]
+Get:134 http://httpredir.debian.org/debian/ jessie/main r-cran-rpart amd64 4.1-8-1 [862 kB]
+Get:135 http://httpredir.debian.org/debian/ jessie/main r-cran-foreign amd64 0.8.61-1 [213 kB]
 [...]
-Fetched 88.2 MB in 2min 17s (642 kB/s)
-Extracting templates from packages: 100%
-Preconfiguring packages ...
+Fetched 124 MB in 52s (2380 kB/s)
+debconf: delaying package configuration, since apt-utils is not installed
 [...]
-Unpacking r-base-core (from .../r-base-core_2.15.1-4_amd64.deb) ...
+Unpacking r-base-core (3.1.1-1+b2) ...
 Selecting previously unselected package r-base-dev.
-Unpacking r-base-dev (from .../r-base-dev_2.15.1-4_all.deb) ...
+Preparing to unpack .../r-base-dev_3.1.1-1_all.deb ...
+Unpacking r-base-dev (3.1.1-1) ...
 Selecting previously unselected package r-cran-boot.
-Unpacking r-cran-boot (from .../r-cran-boot_1.3-5-1_all.deb) ...
+Preparing to unpack .../r-cran-boot_1.3-13-1_all.deb ...
+Unpacking r-cran-boot (1.3-13-1) ...
+Selecting previously unselected package r-cran-mass.
 [...]
-Setting up r-base-core (2.15.1-4) ...
-Setting R_PAPERSIZE_USER default to 'a4'
+Setting up r-base-core (3.1.1-1+b2) ...
 
 Creating config file /etc/R/Renviron with new version
-Setting up r-base-dev (2.15.1-4) ...
-Setting up r-cran-boot (1.3-5-1) ...
+Setting up r-base-dev (3.1.1-1) ...
+Setting up r-cran-boot (1.3-13-1) ...
+Setting up r-cran-mass (7.3-34-1) ...
+Setting up r-cran-class (7.3-11-1) ...
 [...]
 </code></pre>
 </notextile>
@@ -125,11 +142,10 @@ Setting up r-cran-boot (1.3-5-1) ...
 Now we can verify that "R" is installed:
 
 <notextile>
-<pre><code>root@a0e8299b59aa:/# <span class="userinput">R</span>
+<pre><code>root@fbf1d0f529d5:/# <span class="userinput">R</span>
 
-R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"
-Copyright (C) 2012 The R Foundation for Statistical Computing
-ISBN 3-900051-07-0
+R version 3.1.1 (2014-07-10) -- "Sock it to Me"
+Copyright (C) 2014 The R Foundation for Statistical Computing
 Platform: x86_64-pc-linux-gnu (64-bit)
 
 R is free software and comes with ABSOLUTELY NO WARRANTY.
@@ -148,18 +164,21 @@ Type 'q()' to quit R.
 </code></pre>
 </notextile>
 
+Note that you are not limited to installing Debian packages.  You may compile programs or libraries from source and install them, edit systemwide configuration files, use other package managers such as @pip@ or @gem@, and perform any other customization necessary to run your program.
+
 h2. Create a new image
 
-We're now ready to create a new Docker image.  First, quit the container, then use @docker commit@ to create a new image from the stopped container.  The container id can be found in the default hostname of the container displayed in the prompt, in this case @a0e8299b59aa@:
+We're now ready to create a new Docker image.  First, quit the container, then use @docker commit@ to create a new image from the stopped container.  The container id can be found in the default hostname of the container displayed in the prompt, in this case @fbf1d0f529d5@:
 
 <notextile>
-<pre><code>root@a0e8299b59aa:/# <span class="userinput">exit</span>
-$ <span class="userinput">docker commit a0e8299b59aa arvados/jobs-with-r</span>
-33ea6b87792364cb9989a149c36a31e5a9c8cf96694ba05f66545ad7b842522e
+<pre><code>root@fbf1d0f529d5:/# <span class="userinput">exit</span>
+$ <span class="userinput">docker commit fbf1d0f529d5 arvados/jobs-with-r</span>
+sha256:2818853ff9f9af5d7f77979803baac9c4710790ad2b84c1a754b02728fdff205
 $ <span class="userinput">docker images</span>
-REPOSITORY            TAG                 IMAGE ID            CREATED              VIRTUAL SIZE
-arvados/jobs-with-r   latest              33ea6b877923        43 seconds ago       1.607 GB
-arvados/jobs          latest              3132168f2acb        22 hours ago         1.314 GB
+$ docker images |head
+REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
+arvados/jobs-with-r   latest              2818853ff9f9        9 seconds ago       703.1 MB
+arvados/jobs          latest              12b9f859d48c        4 days ago          362 MB
 </code></pre>
 </notextile>
 
@@ -169,17 +188,28 @@ Finally, we are ready to upload the new Docker image to Arvados.  Use @arv keep
 
 <notextile>
 <pre><code>$ <span class="userinput">arv keep docker arvados/jobs-with-r</span>
-1591M / 1591M 100.0%
-Collection saved as 'Docker image arvados/jobs-with-r:latest 33ea6b877923'
-qr1hi-4zz18-3fk2px2ji25nst2
+703M / 703M 100.0%
+Collection saved as 'Docker image arvados/jobs-with-r:latest 2818853ff9f9'
+qr1hi-4zz18-abcdefghijklmno
 $ <span class="userinput">arv keep docker</span>
 REPOSITORY                      TAG         IMAGE ID      COLLECTION                     CREATED
-arvados/jobs-with-r             latest      33ea6b877923  qr1hi-4zz18-3fk2px2ji25nst2    Thu Oct 16 13:58:53 2014
+arvados/jobs-with-r             latest      2818853ff9f9  qr1hi-4zz18-abcdefghijklmno    Tue Jan 17 20:35:53 2017
 </code></pre>
 </notextile>
 
-You are now able to specify the runtime environment for your program using the @docker_image@ field of the @runtime_constaints@ section of your pipeline components:
+You are now able to specify the runtime environment for your program using @DockerRequirement@ in your workflow:
+
+<pre>
+hints:
+  DockerRequirement:
+    dockerPull: arvados/jobs-with-r
+</pre>
+
+h2. Share Docker images
+
+Docker images are subject to normal Arvados permissions.  If wish to share your Docker image with others (or wish to share a pipeline template that uses your Docker image) you will need to use @arv keep docker@ with the @--project-uuid@ option to upload the image to a shared project.
 
 <notextile>
-{% code 'example_docker' as javascript %}
+<pre><code>$ <span class="userinput">arv keep docker --project-uuid qr1hi-j7d0g-xxxxxxxxxxxxxxx arvados/jobs-with-r</span>
+</code></pre>
 </notextile>