repo2docker/docs/source/usage.rst

152 wiersze
5.2 KiB
ReStructuredText
Czysty Zwykły widok Historia

2017-12-07 18:50:46 +00:00
.. _usage:
Using ``repo2docker``
=====================
2017-12-08 19:53:15 +00:00
The core functionality of repo2docker is to fetch a repo (e.g., from GitHub or
other locations) and build a container image based on the specifications found in the
repo. Optionally, it can launch a local Jupyter Notebook which you can use to explore it.
2017-12-07 18:50:46 +00:00
This section describes the general ways in which you can use
2017-12-08 19:53:15 +00:00
``repo2docker``, including:
2017-12-07 18:50:46 +00:00
2017-12-08 19:53:15 +00:00
.. contents::
:depth: 1
:local:
2018-03-15 15:38:19 +00:00
See the `Frequently Asked Questions <faq.html>`_ for additional information.
2017-12-07 18:50:46 +00:00
Preparing your repository
-------------------------
``repo2docker`` looks for configuration files in the repository being built
to determine how to build it. It is philosophically similar to
`Heroku Build Packs <https://devcenter.heroku.com/articles/buildpacks>`_.
Locating and composing configuration files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``repo2docker`` will look for configuration files **located** in two places:
2017-12-07 18:50:46 +00:00
2017-12-08 19:53:15 +00:00
* A folder called ``binder`` in the root of the repository.
* The root of the repository. (If a folder called ``binder`` exists in the root
of the repository, configuration files outside of that folder will be ignored.)
2017-12-07 18:50:46 +00:00
.. note::
In general, ``repo2docker`` uses configuration files that are already part of
various data science workflows (e.g., ``requirements.txt``), rather than
creating new custom configuration files.
2018-04-17 09:03:25 +00:00
``repo2docker`` configuration files are all **composable** - you can use any number
2018-03-15 16:02:12 +00:00
of them in the same repository.
There are a few notable rules for composition precedence and build priority:
2017-12-07 18:50:46 +00:00
* ``Dockerfile``: If a Dockerfile is present in a repository, it will take precedence
2017-12-07 18:50:46 +00:00
over all other configuration files (which will be ignored).
2017-12-08 19:53:15 +00:00
* ``environment.yml`` with ``requirements.txt``: If both of these files are
present, then ``environment.yml`` will be used to build the image, **not**
2017-12-07 18:50:46 +00:00
``requirements.txt``. If you wish to ``pip install`` packages using an
2018-03-15 16:02:12 +00:00
``environment.yml`` file, you should do so with the
``pip:`` key as described in the `conda documentation`_.
2017-12-07 18:50:46 +00:00
.. note::
2017-12-08 19:53:15 +00:00
For a list of repositories demonstrating various configurations,
see :ref:`samples`.
2017-12-07 18:50:46 +00:00
.. *** List of all configuration files ***
2017-12-12 17:46:23 +00:00
.. include:: config_files.txt
2017-12-07 18:50:46 +00:00
2018-03-15 15:38:19 +00:00
Preparing a repo to build JupyterHub-ready images
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-12-12 17:59:08 +00:00
It is possible to use ``repo2docker`` to build JupyterHub-ready
2018-03-15 15:38:19 +00:00
Docker images. For this to work properly, the version of the ``jupyterhub``
2017-12-12 17:59:08 +00:00
package in your git repository must match the version in your JupyterHub
2018-03-15 15:38:19 +00:00
deployment. For example, if your JupyterHub deployment runs ``jupyterhub==0.8``,
2017-12-12 17:59:08 +00:00
you should put the following in ``requirements.txt`` or ``environment.yml``::
jupyterhub==0.8.*
2017-12-07 18:50:46 +00:00
Running ``repo2docker`` locally
-------------------------------
For information on installing ``repo2docker``, see :ref:`install`.
.. note::
Docker must be running on your machine in order to build images
with ``repo2docker``.
The simplest invocation of ``repo2docker`` performs two steps:
1. builds a Docker image from a git repo
2. runs a Jupyter server within the image
2018-03-15 18:34:39 +00:00
This two step process enables you to build an image and run it so you can
explore the repository's contents.
2018-03-15 15:38:19 +00:00
The **command** used is::
2018-04-17 09:03:25 +00:00
jupyter-repo2docker <URL-or-path to repo>
2018-03-15 18:34:39 +00:00
where ``<URL-or-path to repo>`` provides a URL or path to the source repository.
2017-12-07 18:50:46 +00:00
For example, use the following to build an image and launch a Jupyter Notebook
server::
2017-12-07 18:50:46 +00:00
jupyter-repo2docker https://github.com/jakevdp/PythonDataScienceHandbook
When the example completes building (which may take a few minutes), a message will
be output to your terminal::
2017-12-07 18:50:46 +00:00
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://0.0.0.0:36511/?token=f94f8fabb92e22f5bfab116c382b4707fc2cade56ad1ace0
2017-12-08 19:53:15 +00:00
If you copy/paste that URL into your browser you will see a Jupyter Notebook with the
contents of the source repository which you have just built.
2017-12-07 18:50:46 +00:00
Using the ``--debug`` and ``--no-build`` parameters
---------------------------------------------------
If you want to debug and understand the details of the docker image being built,
you can pass the ``debug`` parameter to the commandline:
.. code-block:: bash
2018-03-15 16:02:12 +00:00
jupyter-repo2docker --debug https://github.com/jakevdp/PythonDataScienceHandbook
This will print the generated ``Dockerfile``, build it, and run it.
To see the generated ``Dockerfile`` without actually building it,
pass ``--no-build`` to the commandline. This ``Dockerfile`` output
2018-03-15 18:34:39 +00:00
is for **debugging purposes** of ``repo2docker`` only - it can not
be used by docker directly.
2017-12-07 18:50:46 +00:00
.. code-block:: bash
2017-12-07 18:50:46 +00:00
2018-03-15 16:02:12 +00:00
jupyter-repo2docker --no-build --debug https://github.com/jakevdp/PythonDataScienceHandbook
2017-12-07 18:50:46 +00:00
2018-04-09 19:18:36 +00:00
Setting environment variables
-----------------------------
If you want to define environment variables, you can pass the ``--env`` or ``-e`` parameter to the commandline:
.. code-block:: bash
jupyter-repo2docker -e VAR1=val1 -e VAR2=val2 ...
2017-12-07 18:50:46 +00:00
2017-12-08 19:53:15 +00:00
Accessing help from the command line
------------------------------------
2017-12-07 18:50:46 +00:00
For a list of all the build configurations at your disposal, see the
CLI help::
jupyter-repo2docker -h
2018-03-15 16:02:12 +00:00
.. _conda documentation: https://conda.io/docs/user-guide/tasks/manage-environments.html#creating-an-environment-file-manually