|
| 1 | +.. _docker_image: |
| 2 | + |
| 3 | +Docker image |
| 4 | +============ |
| 5 | + |
| 6 | +Get Docker |
| 7 | +---------- |
| 8 | + |
| 9 | +The first step is to download and install Docker on your platform. |
| 10 | +Refer to the following Docker documentation and choose the best installation |
| 11 | +path for you: `Get Docker <https://docs.docker.com/get-docker/>`_ |
| 12 | + |
| 13 | +Build the Image |
| 14 | +--------------- |
| 15 | + |
| 16 | +VulnerableCode is distributed with ``Dockerfile`` and ``docker-compose.yml`` files |
| 17 | +required for the creation of the Docker image. |
| 18 | + |
| 19 | +Clone the git `VulnerableCode repo <https://github.com/nexB/vulnerablecode>`_, |
| 20 | +create an environment file, and build the Docker image: |
| 21 | + |
| 22 | +.. code-block:: bash |
| 23 | +
|
| 24 | + git clone https://github.com/nexB/vulnerablecode.git && cd vulnerablecode |
| 25 | + make envfile |
| 26 | + docker-compose build |
| 27 | +
|
| 28 | +.. note:: |
| 29 | + |
| 30 | + The image will need to be re-built when the VulnerableCode app source code is |
| 31 | + modified or updated via |
| 32 | + ``docker-compose build --no-cache vulnerablecode`` |
| 33 | + |
| 34 | +Run the Image |
| 35 | +------------- |
| 36 | + |
| 37 | +Run your image as a container |
| 38 | + |
| 39 | +.. code-block:: bash |
| 40 | +
|
| 41 | + docker-compose up |
| 42 | +
|
| 43 | +
|
| 44 | +At this point, the VulnerableCode app should be running at port ``8000`` on your Docker host. |
| 45 | +Go to http://localhost:8000/ on a web browser to access the web UI. |
| 46 | +Optionally, you can set ``NGINX_PORT`` environment variable in your shell or in the `.env` file to run on a different port than 8000. |
| 47 | + |
| 48 | +.. note:: |
| 49 | + |
| 50 | + To access a dockerized VulnerableCode app from a remote location, the ``ALLOWED_HOSTS`` |
| 51 | + setting need to be provided in your ``docker.env`` file:: |
| 52 | + |
| 53 | + ALLOWED_HOSTS=.domain.com,127.0.0.1 |
| 54 | + |
| 55 | + Refer to `Django ALLOWED_HOSTS settings <https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts>`_ |
| 56 | + for documentation. |
| 57 | + |
| 58 | +.. warning:: |
| 59 | + |
| 60 | + Serving VulnerableCode on a network could lead to security issues and there |
| 61 | + are several steps that may be needed to secure such a deployment. |
| 62 | + Currently, this is not recommendend. |
| 63 | + |
| 64 | + |
| 65 | +Invoke the importers |
| 66 | +-------------------- |
| 67 | + |
| 68 | +Connect to the Docker container ``bash``. |
| 69 | +From here you can access ``manage.py`` and run management commands |
| 70 | +to import data as specified in the `Data import <../README.rst#data-import>`_ section and run commands |
| 71 | +for the importers from there |
| 72 | + |
| 73 | +For example: |
| 74 | + |
| 75 | +.. code-block:: bash |
| 76 | +
|
| 77 | + docker-compose exec vulnerablecode bash |
| 78 | + ./manage.py import --list |
| 79 | +
|
| 80 | +
|
0 commit comments