devenvironment.rst 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 make build
  30. If the build is successful, congratulations! You have produced a clean build of
  31. docker, neatly encapsulated in a standard build environment.
  32. Step 4: Build the Docker Binary
  33. -------------------------------
  34. To create the Docker binary, run this command:
  35. .. code-block:: bash
  36. sudo make binary
  37. This will create the Docker binary in ``./bundles/<version>-dev/binary/``
  38. Using your built Docker binary
  39. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  40. The binary is available outside the container in the directory
  41. ``./bundles/<version>-dev/binary/``. You can swap your host docker executable
  42. with this binary for live testing - for example, on ubuntu:
  43. .. code-block:: bash
  44. 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
  45. .. note:: Its safer to run the tests below before swapping your hosts docker binary.
  46. Step 5: Run the Tests
  47. ---------------------
  48. To execute the test cases, run this command:
  49. .. code-block:: bash
  50. sudo make test
  51. Note: if you're running the tests in vagrant, you need to specify a dns entry in
  52. the command (either edit the Makefile, or run the step manually):
  53. .. code-block:: bash
  54. sudo docker run -dns 8.8.8.8 -privileged -v `pwd`:/go/src/github.com/dotcloud/docker docker hack/make.sh test
  55. If the test are successful then the tail of the output should look something like this
  56. .. code-block:: bash
  57. --- PASS: TestWriteBroadcaster (0.00 seconds)
  58. === RUN TestRaceWriteBroadcaster
  59. --- PASS: TestRaceWriteBroadcaster (0.00 seconds)
  60. === RUN TestTruncIndex
  61. --- PASS: TestTruncIndex (0.00 seconds)
  62. === RUN TestCompareKernelVersion
  63. --- PASS: TestCompareKernelVersion (0.00 seconds)
  64. === RUN TestHumanSize
  65. --- PASS: TestHumanSize (0.00 seconds)
  66. === RUN TestParseHost
  67. --- PASS: TestParseHost (0.00 seconds)
  68. === RUN TestParseRepositoryTag
  69. --- PASS: TestParseRepositoryTag (0.00 seconds)
  70. === RUN TestGetResolvConf
  71. --- PASS: TestGetResolvConf (0.00 seconds)
  72. === RUN TestCheckLocalDns
  73. --- PASS: TestCheckLocalDns (0.00 seconds)
  74. === RUN TestParseRelease
  75. --- PASS: TestParseRelease (0.00 seconds)
  76. === RUN TestDependencyGraphCircular
  77. --- PASS: TestDependencyGraphCircular (0.00 seconds)
  78. === RUN TestDependencyGraph
  79. --- PASS: TestDependencyGraph (0.00 seconds)
  80. PASS
  81. ok github.com/dotcloud/docker/utils 0.017s
  82. Step 6: Use Docker
  83. -------------------
  84. You can run an interactive session in the newly built container:
  85. .. code-block:: bash
  86. sudo make shell
  87. # type 'exit' or Ctrl-D to exit
  88. Extra Step: Build and view the Documentation
  89. --------------------------------------------
  90. If you want to read the documentation from a local website, or are making changes
  91. to it, you can build the documentation and then serve it by:
  92. .. code-block:: bash
  93. sudo make docs
  94. # when its done, you can point your browser to http://yourdockerhost:8000
  95. # type Ctrl-C to exit
  96. **Need More Help?**
  97. 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 mailing list <https://groups.google.com/d/forum/docker-dev>`_.