repo2docker/docs/source/usage.rst

101 wiersze
3.8 KiB
ReStructuredText
Czysty Zwykły widok Historia

2017-12-07 18:50:46 +00:00
.. _usage:
Using ``repo2docker``
=====================
`Docker <https://docs.docker.com/>`_ **must be running** in
order to run ``repo2docker``. For more information on installing
``repo2docker``, see :ref:`install`.
2017-12-07 18:50:46 +00:00
``repo2docker`` performs two steps:
2017-12-07 18:50:46 +00:00
1. builds a Docker image from a git repo
2. runs a Jupyter server within the image to explore the repo
2017-12-07 18:50:46 +00:00
To ensure you can run the software in your repository, you must
2018-03-15 16:02:12 +00:00
2018-07-05 18:25:43 +00:00
repo2docker is called with this command::
2017-12-07 18:50:46 +00:00
jupyter-repo2docker <URL-or-path to repo>
2017-12-07 18:50:46 +00:00
where ``<URL-or-path to repo>`` is 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 of the
2018-07-16 05:03:49 +00:00
`Python Data Science Handbook <https://github.com/jakevdp/PythonDataScienceHandbook>`_::
2017-12-12 17:59:08 +00:00
jupyter-repo2docker https://github.com/jakevdp/PythonDataScienceHandbook
2017-12-12 17:59:08 +00:00
2018-07-05 18:25:43 +00:00
To build a particular branch and commit, use the argument ``--ref`` to
specify the ``branch-name`` or ``commit-hash``::
2017-12-12 17:59:08 +00:00
jupyter-repo2docker https://github.com/jakevdp/PythonDataScienceHandbook --ref 599aa0fe3f882c0001670e676e5a8d43b92c35fc
2017-12-07 18:50:46 +00:00
.. tip::
For reproducibile research, we recommend specifying a commit-hash to
deterministcally build a fixed version of a repository. Not specifying a
commit-hash will result in the latest commit of the repository being built.
2018-07-05 18:25:43 +00:00
Building the image may take a few minutes.
2018-06-27 01:01:13 +00:00
During building, ``repo2docker``
clones the repository to obtain its contents and inspects the repo for
:ref:`configuration files <config-files>`.
2018-07-02 03:51:40 +00:00
By default, ``repo2docker`` will assume you are using
Python 3.6 unless you include the version of Python in your
:ref:`configuration files <config-files>`. ``repo2docker`` support is best with
Python 2.7, 3.5, and 3.6. In the case of this repo, a Python version is not
specified in their configuation files and Python 3.6 is installed.
2018-07-16 05:03:49 +00:00
`Python Data Science Handbook <https://github.com/jakevdp/PythonDataScienceHandbook>`_
uses a `requirements.txt file <https://github.com/jakevdp/PythonDataScienceHandbook/blob/master/requirements.txt>`_
to specify its Python environment. ``repo2docker`` uses ``pip`` to install
2018-07-05 18:25:43 +00:00
dependencies listed in the ``requirement.txt`` in the image. To learn more about
configuration files in ``repo2docker`` visit :ref:`config-files`.
2017-12-07 18:50:46 +00:00
When the image is built, a message will be output to your terminal::
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
Pasting the URL into your browser will open Jupyter Notebook with the
dependencies and contents of the source repository in the built image.
Because JupyterLab is a server extension of the classic Jupyter Notebook server,
you can launch JupyterLab by opening Jupyter Notebook and visiting the
```/lab`` to the end of the URL:
.. code-block:: none
2017-12-07 18:50:46 +00:00
http(s)://<server:port>/<lab-location>/lab
2017-12-07 18:50:46 +00:00
To switch back to the classic notebook, add ``/tree`` to the URL:
2017-12-07 18:50:46 +00:00
.. code-block:: none
2017-12-07 18:50:46 +00:00
http(s)://<server:port>/<lab-location>/tree
2017-12-07 18:50:46 +00:00
To learn more about URLs in JupyterLab and Jupyter Notebook, visit
`starting JupyterLab <http://jupyterlab.readthedocs.io/en/latest/getting_started/starting.html>`_.
2017-12-07 18:50:46 +00:00
``--debug`` and ``--no-build``
------------------------------
To debug the docker image being built, pass the ``--debug`` parameter:
.. 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