devenvironment.rst 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. :title: Setting Up a Dev Environment
  2. :description: Guides on how to contribute to docker
  3. :keywords: Docker, documentation, developers, contributing, dev environment
  4. Setting Up a Dev Environment
  5. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  6. To make it easier to contribute to Docker, we provide a standard
  7. development environment. It is important that the same environment be
  8. used for all tests, builds and releases. The standard development
  9. environment defines all build dependencies: system libraries and
  10. binaries, go environment, go dependencies, etc.
  11. Step 1: Install Docker
  12. ----------------------
  13. Docker's build environment itself is a Docker container, so the first
  14. step is to install Docker on your system.
  15. You can follow the `install instructions most relevant to your system
  16. <https://docs.docker.io/en/latest/installation/>`_. Make sure you have
  17. a working, up-to-date docker installation, then continue to the next
  18. step.
  19. Step 2: Check out the Source
  20. ----------------------------
  21. .. code-block:: bash
  22. git clone http://git@github.com/dotcloud/docker
  23. cd docker
  24. To checkout a different revision just use ``git checkout`` with the name of branch or revision number.
  25. Step 3: Build the Environment
  26. -----------------------------
  27. This following command will build a development environment using the Dockerfile in the current directory. Essentially, it will install all the build and runtime dependencies necessary to build and test Docker. This command will take some time to complete when you first execute it.
  28. .. code-block:: bash
  29. sudo docker build -t docker .
  30. If the build is successful, congratulations! You have produced a clean build of docker, neatly encapsulated in a standard build environment.
  31. Step 4: Build the Docker Binary
  32. -------------------------------
  33. To create the Docker binary, run this command:
  34. .. code-block:: bash
  35. sudo docker run -privileged -v `pwd`:/go/src/github.com/dotcloud/docker docker hack/make.sh binary
  36. This will create the Docker binary in ``./bundles/<version>-dev/binary/``
  37. Step 5: Run the Tests
  38. ---------------------
  39. To execute the test cases, run this command:
  40. .. code-block:: bash
  41. sudo docker run -privileged -v `pwd`:/go/src/github.com/dotcloud/docker docker hack/make.sh test
  42. Note: if you're running the tests in vagrant, you need to specify a dns entry in the command: `-dns 8.8.8.8`
  43. If the test are successful then the tail of the output should look something like this
  44. .. code-block:: bash
  45. --- PASS: TestWriteBroadcaster (0.00 seconds)
  46. === RUN TestRaceWriteBroadcaster
  47. --- PASS: TestRaceWriteBroadcaster (0.00 seconds)
  48. === RUN TestTruncIndex
  49. --- PASS: TestTruncIndex (0.00 seconds)
  50. === RUN TestCompareKernelVersion
  51. --- PASS: TestCompareKernelVersion (0.00 seconds)
  52. === RUN TestHumanSize
  53. --- PASS: TestHumanSize (0.00 seconds)
  54. === RUN TestParseHost
  55. --- PASS: TestParseHost (0.00 seconds)
  56. === RUN TestParseRepositoryTag
  57. --- PASS: TestParseRepositoryTag (0.00 seconds)
  58. === RUN TestGetResolvConf
  59. --- PASS: TestGetResolvConf (0.00 seconds)
  60. === RUN TestCheckLocalDns
  61. --- PASS: TestCheckLocalDns (0.00 seconds)
  62. === RUN TestParseRelease
  63. --- PASS: TestParseRelease (0.00 seconds)
  64. === RUN TestDependencyGraphCircular
  65. --- PASS: TestDependencyGraphCircular (0.00 seconds)
  66. === RUN TestDependencyGraph
  67. --- PASS: TestDependencyGraph (0.00 seconds)
  68. PASS
  69. ok github.com/dotcloud/docker/utils 0.017s
  70. Step 6: Use Docker
  71. -------------------
  72. You can run an interactive session in the newly built container:
  73. .. code-block:: bash
  74. sudo docker run -privileged -i -t docker bash
  75. # type 'exit' to exit
  76. .. note:: The binary is available outside the container in the directory ``./bundles/<version>-dev/binary/``. You can swap your host docker executable with this binary for live testing - for example, on ubuntu: ``sudo service docker stop ; sudo cp $(which docker) $(which docker)_ ; sudo cp ./bundles/<version>-dev/binary/docker-<version>-dev $(which docker);sudo service docker start``.
  77. **Need More Help?**
  78. If you need more help then hop on to the `#docker-dev IRC channel <irc://chat.freenode.net#docker-dev>`_ or post a message on the `Docker developer mailinglist <https://groups.google.com/d/forum/docker-dev>`_.